2

I have to issue a CTRL+M action in WebdriverIO, but it is not working.

I have tried using different ways such as:

  • browser.keys('Control').keys('m');
  • browser.keys(['Control','KeyM', 'NULL']);
  • browser.keys(['Control', 'm', 'NULL']);
  • browser.keys('Control').keys('KeyM');
  • browser.deviceKeyEvent(82); browser.pressKeycode(82); browser.keys('MENU');

None of the above are working. Can anyone help me?

iamdanchiv
  • 3,828
  • 4
  • 32
  • 40
Payal
  • 33
  • 9

1 Answers1

3

Short answer, NO. You currently cannot chain key commands with any driver configuration. .keys() does in fact still work with chromedriver(only sending text, no chaining), yet it has been marked for deprecation. See list bellow for more details.

Dependencies:

"selenium-standalone": "^5.11.2",
"wdio-selenium-standalone-service": "0.0.8",
"webdriverio": "4.8.0"

Driver versions affected:

ChromeDriver: 2.29-x64-chromedriver
GeckoDriver:  0.16.0-x64-geckodriverIEDriver:
3.4.0-x64-IEDriverServer

What is wrong with the .keys() command?

  • this is a known issue throughout the Selenium community and won't be fixed/tackled in WebdriverIO until the drivers (chromedriver, geckodriver, etc.) implement Webdriver's new W3C standard for user input, Actions API;
  • there is not other way of doing this (trust me, I tried!), unless you can actually substitute the functionality of your CTRL + M action via code;
  • here is a BUG that documents this issue for GeckoDriver (Firefox);
  • even if the .keys() method is working with your current version, Christian-Bromann confirmed it will be deprecated in the next release (it is also marked for deprecation in the /lib/protocol/keys.js definition file).

Note: For anyone having similar issues with different WDIO commands, the deprecation of .keys()(WDIO), .sendKeys()(WebdriverJS) also applies to other broken WebdriverIO methods like .moveTo(). Read more about it here.

iamdanchiv
  • 3,828
  • 4
  • 32
  • 40
  • @Payal, what is the behavior triggered by the `CTRL+M` command? Anyways you should find a workaround via code. Consider accepting the answer so it becomes visible to other users struggling with this issue. – iamdanchiv May 17 '17 at 08:09
  • Actually, I am clicking on first button.Then I have to click on CTRL+M... after that, I have to click on second button.So after clicking on first button, it is not clicking on CTRL+M and searching for second button.As it is not present,so it is displaying the error as 'cannot find the element using given locator' after timeout. – Payal May 22 '17 at 06:50
  • @Payal Yes, unfortunately chaining keys in **WebdriverIO** is not possible right now as per my above response. You can still try to *emulate* the `CTRL+M` command via code (via `.execute()`). What does `CTRL+M` try to achieve in your test? (e.g.: open a file, close a window, select some text) – iamdanchiv May 22 '17 at 07:20
  • In my emulator, it is not displaying the logout button of application which is present on the real device.So in manual testing,if I click the CTRL+M,after clicking the first button,it gives me the popup for logout button in emulator.Then clicking on confirm logout button,my task ends. Butwhile performing automation, it is not clicking on CTRL+M. – Payal May 22 '17 at 11:10
  • @iamdanchiv I am on WDIO5 has something changed? Need to paste with CTRL+V – Gobliins Mar 13 '20 at 12:42