[如何在Chrome浏览器中使用ruby执行ctrl + j。我正在使用RubyMine和WatirWebdriver

问题描述 投票:0回答:1

[尝试以下代码单击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。

ruby-on-rails ruby watir browser-automation
1个回答
0
投票

首先,

您发送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().
© www.soinside.com 2019 - 2024. All rights reserved.