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

杀马特。学长 韩版系。学妹 提交于 2019-12-11 01:23:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/43938015/how-to-click-on-ctrlm-control-m-in-webdriverio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!