5

I'm running a Watir test using Ruby and Watir-Webdriver and the Headless gem.

Here is the code that sets up the Headless environment:

headless = Headless.new(dimensions: "1600x900x24")

If a test crashes, our test environment automatically captures a screen shot. I expected to see screen shots that were 1600x900, yet the images are about 1050 x 818 (+/- a few pixels), and the web pages themselves are scaled to fit in this area.

I changed the headless dimensions to 3200x1800x24, and my screen shot was 1585 x 1718. I changed the headless dimensions to 50x90x24 and the screen shot was 187 x 8, and in this case the entire web page was not visible.

Any explanation for this behavior? How do I set my headless screen to be 1600 x 900? I'm wondering if this is an issue with Xvfb, or the way Headless works with Xvfb, but I don't know much about how that works and the reading I did on Xvfb today didn't illuminate things for me.

It's less the screen shots that I care about and more the scaling of the page to fit the reduced dimensions of 1050 x 818. At that size, certain page elements for a test I am writing are wrapped on the screen and not clickable, which is causing the test to crash in the first place.

pjd
  • 1,163
  • 8
  • 17

1 Answers1

0

I've previously had this problem running headless on a Jenkins server. The issue was with Xvfb . You can set screen resolution at the command line, like this:

Xvfb :1 -screen 0 1600x900x24
Johnson
  • 1,510
  • 8
  • 15
  • Thanks for your reply. I've been trying to implement your suggestion for a few hours but as yet it hasn't worked for me. I got a lot of errors, several of which I cleared up with some Googling. Hopefully I can figure out how to get past this one, which is reported in a few places on the web but which does not have a fix that I have yet found that works on my machine: "[dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!" Then I can move on with my Watir test! – pjd Sep 16 '14 at 19:24
  • Hm, I've never run into this issue. Could you post the command you're using to initiate Xvfb? – Johnson Sep 16 '14 at 20:02
  • If I copy and paste the command you suggested above, I get the error message I reported about TrueType, which causes the system to hang and I never get a command prompt back. `sh -e '/usr/bin/Xvfb :1 -screen 0 1600x900x24'` says "sh: 0: Can't open /usr/bin/Xvfb :1 -screen 0 1600x900x24." My TrueType directory is empty, not sure if that is right or not. `sudo dpkg-query -W -f='${Status} ${Package}' xvfb` reports "install ok installed xvfb." `sudo apt-get -y install x-ttcidfont-conf cabextract ttf-mscorefonts-installer` tells me I do have the newest version of x-ttcidfont-conf. – pjd Sep 17 '14 at 15:01
  • Yeah, I'm at a loss for that. After looking over some configuration, this is more like my command, so maybe give it a try? Sorry I can't be of more help. `Xvfb :0 -ac -screen 0 1600x900x24; export DISPLAY=:0` – Johnson Sep 17 '14 at 15:53
  • Alas, that command didn't get me any further. Thanks very much for your efforts. Hopefully I'll figure it out. If I do I'll post an update. – pjd Sep 17 '14 at 21:06