I am trying to run Protractor e2e tests inside a Vagrant VM using headless Chrome. I managed to get it working by using Xvfb but when I run a test to fill a form I get an error: unknown error: an X display is required for keycode conversions, consider using Xvfb
All tests run fine but as soon as I use getKeys() (e.g. element(by.model('user.email')).sendKeys('admin'); ) I get this error, even though I am already using Xvfb.
I'm running:
- AngularJS sample app generated with the Yeoman angular-fullstack generator
- Nodejs version 0.10.30, installed with nvm
- Vagrant 1.6.3
- VirtualBox 4.3.14
- Host OS Ubuntu 14.04 32 bits
- Guest OS Ubuntu 14.04 32 bits
- chrome 37.0.2062.94
- chromedriver 2.10.267517
I use the following shell script to start Selenium and Xvfb:
#!/bin/sh
webdriver-manager start &
Xvfb :1 -ac -screen 0 1280x1024x8 &
export DISPLAY=:1
I also added "export DISPLAY=:1" to /opt/google/chrome/google-chrome. Again, tests without sendKeys() run fine.
What I have done so far:
- I'm running 32 bits Ubuntu so I downloaded chromedriver 2.10 32 bits but that didn't help
- I ran chromedriver with --verbose and checked the logs but that only shows the same error
- I fiddled with the Xvfb screen dimension settings, didn't help either
- I checked some source code here: https://github.com/bayandin/chromedriver/blob/master/keycode_text_conversion_x.cc and found the error message on line 196. It's triggered when the command gfx::GetXDisplay() (line 193) doesn't get a display object. I suspect that it might be just the DISPLAY variable I export in /opt/google/chrome/google-chrome but I'm not sure and have no idea how to fix it.
I would like to know how I can get sendfkeys() working with headless Chrome inside a Vagrant VM. Any help is greatly appreciated.