Search code examples
javascriptmocha.jsappiumwebdriver-io

How to click on CTRL+M (Control + M) in WebdriverIO


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?


Solution

  • 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.