尝试了以下代码来单击ctrl+J,但不适用于chrome浏览器。@browser.driver.action.key_down(:control.(.send_keys("j"(.key_up(:control..执行也尝试过@browser.driver.action.send_keys(:control,"J"(执行
我在一个博客上读到,上面的代码适用于Firefox浏览器,但不适用于Chrome。
首先,
您发送control+j
的方式错误。发送control+j
的方法是,你必须像[:control,"j]
一样在[]
内部给予控制+k
b.send_keys([:control,"j"])
第二关,
由于以下问题,无法通过chromedriver发送[:control,"j]
https://bugs.chromium.org/p/chromedriver/issues/detail?id=903
准确的答案就在这里
This is a limitation in the way we simulate keyboard input in ChromeDriver. Keys get sent directly to the render process, bypassing the browser process. So any keyboard shortcut handlers in the browser process will not be invoked by sendKeys().