New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendKeys function does not work with headless chrome. #4332

Closed
ershwetabansal opened this Issue Jun 16, 2017 · 13 comments

Comments

Projects
None yet
8 participants
@ershwetabansal
Copy link

ershwetabansal commented Jun 16, 2017

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
@wswebcreation

This comment has been minimized.

Copy link
Collaborator

wswebcreation commented Jun 16, 2017

Just a check, but have you tried upgrading nom to 6.9.x because that's was Protractor requires?

@ershwetabansal

This comment has been minimized.

Copy link

ershwetabansal commented Jun 16, 2017

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.

@wswebcreation

This comment has been minimized.

Copy link
Collaborator

wswebcreation commented Jun 16, 2017

By the way, I've tried to test with:

  • Node Version: 7.5.0
  • Protractor Version: 5.1.2
  • Angular Version: 4
  • Browser(s): Chrome headless 59.0.3071.104
  • Operating System and Version: Mac oSX Siera 10.12.5 (16F73)

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

@ershwetabansal

This comment has been minimized.

Copy link

ershwetabansal commented Jun 17, 2017

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)
@wswebcreation

This comment has been minimized.

Copy link
Collaborator

wswebcreation commented Jun 17, 2017

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

@NickTomlin

This comment has been minimized.

Copy link
Member

NickTomlin commented Jun 17, 2017

Agreed; this is going to be an issue with your OS. I'm going to go ahead and close this.

@wswebcreation thanks for troubleshooting!

@NickTomlin NickTomlin closed this Jun 17, 2017

@victornoel

This comment has been minimized.

Copy link

victornoel commented 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

@ershwetabansal

This comment has been minimized.

Copy link

ershwetabansal commented Jul 13, 2017

I will be very happy once that happens.

@w-A-L-L-e

This comment has been minimized.

Copy link

w-A-L-L-e commented Jul 17, 2017

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

@alexrashed

This comment has been minimized.

Copy link

alexrashed commented Jul 25, 2017

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

@jogjitu

This comment has been minimized.

Copy link

jogjitu commented Aug 24, 2017

I am still not able get sendkeys working on 2.31. Is it resolved?

@ershwetabansal

This comment has been minimized.

Copy link

ershwetabansal commented Aug 24, 2017

Yeah it is resolved. I have been running my tests with headless chrome smoothly now. What error do you get?

@cb109

This comment has been minimized.

Copy link

cb109 commented Aug 30, 2017

Can confirm this fixes testrun issues with the sendKeys() method (in my case inside nightwatch as either setValue() or keys()). Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment