When I am trying to run protractor in headless environment using headless chrome (v 59), I get error on the point where sendKeys() function is tried to run.
6.1.25.1.21.4.1Chrome headlessLinux homestead 4.4.0-66-generic #87-Ubuntucapabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['--window-size=1800,2000', '--headless', "--disable-gpu"]
}
},
sendKeys anywhere in the tests``` Message:
WebDriverError: unknown error: an X display is required for keycode conversions, consider using Xvfb
(Session info: headless chrome=59.0.3071.86)
(Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.0-66-generic x86_64)
Stack:
WebDriverError: unknown error: an X display is required for keycode conversions, consider using Xvfb
(Session info: headless chrome=59.0.3071.86)
(Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.0-66-generic x86_64)
at WebDriverError (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/error.js:505:15)
at parseHttpResponse (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebElement.sendKeys()
at Driver.schedule (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/webdriver.js:816:17)
at WebElement.schedule_ (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/webdriver.js:1921:25)
at WebElement.sendKeys (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/webdriver.js:2084:19)
at actionFn (/home/vagrant/Code/cms/node_modules/protractor/lib/element.ts:94:34)
at Array.map (native)
at actionResults.getWebElements.then (/home/vagrant/Code/cms/node_modules/protractor/lib/element.ts:484:67)
at ManagedPromise.invokeCallback_ (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/promise.js:1366:14)
at TaskQueue.execute_ (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/promise.js:2970:14)
at TaskQueue.executeNext_ (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/promise.js:2953:27)
at asyncRun (/home/vagrant/Code/cms/node_modules/selenium-webdriver/lib/promise.js:2813:27)Error
at ElementArrayFinder.applyAction_ (/home/vagrant/Code/cms/node_modules/protractor/lib/element.ts:482:23)
at ElementArrayFinder.(anonymous function) [as sendKeys] (/home/vagrant/Code/cms/node_modules/protractor/lib/element.ts:96:21)
at ElementFinder.(anonymous function) [as sendKeys] (/home/vagrant/Code/cms/node_modules/protractor/lib/element.ts:873:14)
````
sendKeys in the tests and try to run protractor in headless environment without xvfbJust a check, but have you tried upgrading nom to 6.9.x because that's was Protractor requires?
No, my node version is still old one. I will try to do the same over the weekend to see if it works and will get back to you. Thanks.
By the way, I've tried to test with:
And it's working with .sendKeys('string'), so I'm wondering what the node upgrade will do for you. Do you also use NVM, could be useful to easily switch between node versions
Thanks for the tip on nvm.
I installed node 8.1.2 but I still get the same issue. I have installed homestead vm on my mac and running these tests on that instead of mac. I am in the process of automating the tests so there is no point in trying and make it work on Mac OS. Any clues?
Failed: unknown error: an X display is required for keycode conversions, consider using Xvfb
(Session info: headless chrome=59.0.3071.104)
(Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.0-66-generic x86_64)
The error you get now is related to this question on SO
https://stackoverflow.com/q/44597107/5911978
I would suggest to close the question here because, in my opinion, it is not related to Protractor, but or Chrome/Chromedriver/OS.
Tnx
Agreed; this is going to be an issue with your OS. I'm going to go ahead and close this.
@wswebcreation thanks for troubleshooting!
For the record, the problem is in chromedriver and is/will be fixed in 2.31, see https://bugs.chromium.org/p/chromedriver/issues/detail?id=1772
I will be very happy once that happens.
We had same issue of needing 'native headless sendkeys' for testing file uploads.
Until chromedriver 2.31 is released there is a patched 2.30 here that worked for us:
https://github.com/davidthornton/chromedriver-2.31/blob/master/chromedriver
The official 2.31 is not released but when it is it will deprecate above link of course:
https://sites.google.com/a/chromium.org/chromedriver/downloads
FYI: ChromeDriver 2.31 has been released yesterday.
The release fixed the mentioned bug in my test environment.
I am still not able get sendkeys working on 2.31. Is it resolved?
Yeah it is resolved. I have been running my tests with headless chrome smoothly now. What error do you get?
Can confirm this fixes testrun issues with the sendKeys() method (in my case inside nightwatch as either setValue() or keys()). Thanks for sharing!
Most helpful comment
FYI: ChromeDriver 2.31 has been released yesterday.
The release fixed the mentioned bug in my test environment.