[尝试以下代码单击ctrl + J,但不适用于chrome浏览器。@ browser.driver.action.key_down(:control).send_keys(“ j”)。key_up(:control).perform也试过了@ browser.driver.action.send_keys(:control,“ J”)。perform
我读过一个博客,以上代码适用于Firefox浏览器,但不适用于Chrome。
首先,
您发送control+j
的方式是错误的。发送control+j
的方法是,您必须像[]
]一样在[:control,"j]
中提供control + 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().