How to take Retina Screenshots with Xvfb and Selenium -


i want take screenshots of hybrid app itunes connect automatically. running ubuntu 14.04. chromedriver 2.15.322448

taking screenshots automatically easy selenium , xvfb. not easy retina screenshots.

i started xvfb higher dpi:

/usr/bin/xvfb :99 -screen 0 2000x2000x24 -dpi 200 

when check display information seems right:

xdpyinfo -display :99  ... screen #0:   dimensions:    2000x2000 pixels (254x254 millimeters)   resolution:    200x200 dots per inch   depths (6):    24, 1, 4, 8, 16, 32 ... 

then start chromedriver this

private webdriver getchromedriver ( phone phone ) {     map<string, object> devicemetrics = new hashmap<string, object>();     devicemetrics.put("width", 320);     devicemetrics.put("height", 460);     devicemetrics.put("pixelratio", 2);     map<string, object> mobileemulation = new hashmap<string, object>();     mobileemulation.put("devicemetrics", devicemetrics);     mobileemulation.put("useragent", "iphone4");      chromedriverservice cds = new chromedriverservice.builder().withenvironment(immutablemap.of("display", ":99")).build();      map<string, object> chromeoptions = new hashmap<string, object>();     chromeoptions.put("mobileemulation", mobileemulation);     desiredcapabilities capabilities = desiredcapabilities.chrome();     capabilities.setcapability(chromeoptions.capability, chromeoptions);     webdriver driver = new chromedriver(cds, capabilities);     return driver; } 

and after other boring code, take screenshot:

 file srcfile = ( (takesscreenshot) driver ).getscreenshotas(outputtype.file); 

this not work. screenshot in regular dpi. image of website captured 320x460 , not 640x960 should be.

i set breakpoint before screenshot taken , dumped framebuffer this:

export display=:99  xwd -root -silent | xwdtopnm |pnmtojpeg > screen.jpg 

result of xwd dumping content of virtual framebuffer

as can see title bar rendered in respect higher dpi rest of browser window not.

so how can run chromedriver more dpi take retina screenshots? possible?

i'm facing same problem , still stuck following may useful. allowed me rule out either xvfb or chrome attaching vnc connection xvfb framebuffer.

#!/bin/bash export geometry="$screen_width""x""$screen_height""x""$screen_depth"  function shutdown {   kill -s sigterm $node_pid   wait $node_pid }  sudo -e -i -u seluser \   display=$display \   xvfb-run --server-args="$display -screen 0 $geometry -dpi 300 -ac +extension randr" \   java -jar /opt/selenium/selenium-server-standalone.jar & node_pid=$!  trap shutdown sigterm sigint in $(seq 1 10)   xdpyinfo -display $display >/dev/null 2>&1   if [ $? -eq 0 ];     break   fi   echo waiting xvfb...   sleep 0.5 done  fluxbox -display $display &  x11vnc -forever -usepw -shared -rfbport 5900 -display $display &  wait $node_pid 

after vnc'ing in, google-chrome gui can loaded terminal. navigation web pages confirm chrome rendering pages correct dpi. screenshot http://i.stack.imgur.com/iejo0.jpg

i working please reach out if have new developments. used https://registry.hub.docker.com/u/selenium/standalone-chrome-debug/ btw.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -