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.
webdriver-manager start &
Xvfb :1 -ac -screen 0 1280x1024x8 &
Ensure seleniumAddress: 'http://localhost:4444/wd/hub' matches your selenium server and avoid setting
chromeOnly since that will effectively avoid using the headless selenium server.
Also, Xvfb needs to run before
webdriver-manager and you're missing
xvfb-run given you seem to need it to do the X authority dance for you:
#!/bin/sh export DISPLAY=:1 Xvfb $DISPLAY -ac -screen 0 1280x1024x8 & sleep 1 xvfb-run webdriver-manager start &
In case you're interested I've setup a headless docker based solution with optional VNC access plus video recording: https://github.com/elgalu/docker-selenium