Skip to content
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

Keys are not working with webdriverIO #1344

Closed
kedunuru opened this issue May 26, 2016 · 25 comments
Closed

Keys are not working with webdriverIO #1344

kedunuru opened this issue May 26, 2016 · 25 comments

Comments

@kedunuru
Copy link

Keys are not working with webdriverIO ....
I am trying to use keys to simulate command+i
None of the options are working....
driver.keys(['\uE03D', '\u0049']);
driver.keys(['meta','i']);

Environment

  • WebdriverIO version:
  • Node.js version: 4.4.3

when I read in forums, there was a indication that it is an issue with chrome driver, is this resolved or is it still an issue?

Thanks,
Veni

@pi4r0n
Copy link

pi4r0n commented May 27, 2016

@kedunuru have you tried to use it that way

driver.keys('Enter')
driver.keys('F5')

@kedunuru
Copy link
Author

yeah i tried that as well :)

@christian-bromann
Copy link
Member

This is probably Selenium related.

@kedunuru
Copy link
Author

kedunuru commented Jun 1, 2016

I have tried one more time using
:driver.keys('Enter')
driver.keys('F5')
It does not work

@pi4r0n
Copy link

pi4r0n commented Jun 1, 2016

@kedunuru can you post you selenium version and sample code please.

@kurtharriger
Copy link

Keys is working fine for me (4.0.9) with selenium 2.53 and chrome, and several browsers on saucelabs which still uses 2.48.

The following package will install selenium and chrome driver for you. Perhaps you have some version incompatibilities with selenium and chrome driver?
https://www.npmjs.com/package/selenium-standalone

If that doest work you'll probably need to be more specific about your setup

@marinatells
Copy link

marinatells commented Jun 21, 2016

I have partly the same issue

selenium server: 2.53
chrome driver: 2.21
selenium-standalone npm package: 5.1.1
webdriverio: 4.0.9

i've tried

driver.keys(['Control', 'v'])
driver.keys(['Control, 'a'])

however, simple keys are sent, i. e.

driver.keys(['some','word'])
driver.keys('some word')

@christian-bromann
Copy link
Member

christian-bromann commented Jun 21, 2016

@lladrona try Command instead of Control or Meta maybe. This is usually not an issue with WebdriverIO but the browser driver.

@marinatells
Copy link

marinatells commented Jun 23, 2016

@christian-bromann i've tried both command and control, nothing changes
then inspected server logs for browser.keys(['Command', 'c']); in chrome, phantomjs, firefox

12:01:42.611 INFO - Executing: [send keys to active: [, c]])
12:01:42.626 INFO - Done: [send keys to active: [, c]]

we have tests written in java, and their SendKeys ends up like

12:01:42.611 INFO - Executing: [send keys to active: [, ]])
12:01:42.626 INFO - Done: [send keys to active: [, ]]

is this still browser driver issue and could this be the problem?

@monolithed
Copy link

I can confirm the problem. It does not depend on the version of the Selenium or WebDriver.

@jeffmanhart
Copy link

jeffmanhart commented Jun 23, 2016

I am able to use browser.keys('Enter') successfully on all browsers except using safaridriver. This I believe to be a safaridriver issue but figured I would mention it here as well. Additionally I tried to use 'Return', and '\n' but all fail in same fashion.
Err message is -
Failed: Unknown command: {"id":"eh7bqx6syufe","name":"sendKeysToActiveElement","parameters":{"value":[""]}} (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 4 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
os.version: '10.10.5', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{browserName=safari, takesScreenshot=true, javascriptEnabled=true, version=9.1.1, cssSelectorsEnabled=true, platform=MAC, secureSsl=true}]
Session ID: null

@timbru31
Copy link
Contributor

timbru31 commented Jun 27, 2016

@jeffmanhart AFAIK Safari does not support browser.keys yet: SeleniumHQ/selenium-google-code-issue-archive#4136

edit
We also had issues sending CTRL keys to the Internet Explorer and did not solve this. Simple combinations without CTRL or ALT worked though.

@ghost
Copy link

ghost commented Aug 31, 2016

chrome driver: 2.21.2
webdriverio: 4.0.4

I had issues sending key combinations with modifiers, too.
In the docs at http://webdriver.io/api/protocol/keys.html I found out, that the modifiers (Control, Shift, Alt) are not released by default. You have to pass 'NULL' to release the modifier key.

browser.keys(['Control', 'r', 'NULL'])

Another gotcha I had, was that the character type keys on https://w3c.github.io/webdriver/webdriver-spec.html#h-keyboard-actions (which was linked in the docs), are not identical to those that webdriverio is using. They have to match exactly in case to work.
The character type keys which webdriverio is using can be found here: https://github.com/webdriverio/webdriverio/blob/master/lib/helpers/constants.js#L67

And update to the docs and maybe an example on how to use key combinations with modifiers would be helpful.

@christian-bromann
Copy link
Member

are not identical to those that webdriverio is using

@bekite this got updated

@christian-bromann
Copy link
Member

... and released. If some keys aren't working in some browser is probably an issue of the driver. Closing.

@gogoyqj
Copy link

gogoyqj commented Apr 27, 2017

seems firefox webdriver doesn't support this api

@christian-bromann
Copy link
Member

@gogoyqj you are right

@pmerwin
Copy link
Contributor

pmerwin commented Aug 1, 2017

Any updates on ff driver having a fix?

@christian-bromann
Copy link
Member

It won't as this command is not part of the WebDriver protocol

@pmerwin
Copy link
Contributor

pmerwin commented Aug 2, 2017

@christian-bromann I see that is deprecated, what command will replace 'keys'?

@christian-bromann
Copy link
Member

Keyboard actions: https://www.w3.org/TR/webdriver/#keyboard-actions

@rsshilli
Copy link

So... how do we use those "Keyboard Actions" from webdriver.io? The keys() method doesn't seem to use that and I don't see any other options.

@rsshilli
Copy link

@kajmagnus
Copy link

This worked for me, in FF, to click Return: https://sqa.stackexchange.com/a/27860/32461:

element.setValue(`${value}\n`);

that is, appendnig \n

(but no answers on the StackOverflow page linked just above worked, in FF)

@chandanrayarm
Copy link

chandanrayarm commented Feb 5, 2020

Hi there I'm trying to work Option+Command+W key to work but its not working can someone help me here as client.keys(['Option, 'Command', 'W']);

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

No branches or pull requests