question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sendKeys function does not work with headless chrome.

See original GitHub issue

Bug report

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.

  • Node Version: 6.1.2
  • Protractor Version: 5.1.2
  • Angular Version: 1.4.1
  • Browser(s): Chrome headless
  • Operating System and Version Linux homestead 4.4.0-66-generic #87-Ubuntu
  • Your protractor configuration file
capabilities: {
      'browserName': 'chrome',
      'chromeOptions': {
        'args': ['--window-size=1800,2000', '--headless', "--disable-gpu"]
      }
    },
  • A relevant example test Use of sendKeys anywhere in the tests
  • Output from running the test
    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)
  • Steps to reproduce the bug Use sendKeys in the tests and try to run protractor in headless environment without xvfb
  • The URL you are running your tests against (if relevant) Not applicable

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
alexrashedcommented, Jul 25, 2017

FYI: ChromeDriver 2.31 has been released yesterday. The release fixed the mentioned bug in my test environment.

4reactions
victornoelcommented, Jul 13, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

2521 - SendKeys to directory file input does not send keys ...
In this application we've an input field, that allows the user to select a directory (does only work in FF, Chrome and Edge)...
Read more >
Selenium with Python: send_keys() doesn't work on ...
So any keyboard shortcut handlers in the browser process will not be invoked by sendKeys(). You can use following code instead: driver.
Read more >
SendKeys Not Behaving correctly going from Chrome ...
What i am seeing is i have a protractor test running on headless chrome with chrome driver and it looks like this: it('Should...
Read more >
Why does the Selenium SendKeys function not work ...
I downloaded the latest version of “Chromedriver”, and replaced it with the current driver I had. It worked! Apparently Chrome v.65> would require...
Read more >
WebElement sendKeys not working under Jenkins/Linux
Do you have the same issue with headless Chrome on the linux box? 2.) Which part of the method is failing, specifically? Is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found