Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ruby Selenium中移动鼠标(移动到)_Ruby_Selenium_Webdriver_Mouse_Watir - Fatal编程技术网

在ruby Selenium中移动鼠标(移动到)

在ruby Selenium中移动鼠标(移动到),ruby,selenium,webdriver,mouse,watir,Ruby,Selenium,Webdriver,Mouse,Watir,我试图用Ruby中的SeleniumWebDriver 2.4模拟鼠标移动 如果我运行测试,是否应该看到鼠标在屏幕上移动?我很困惑 我试过很多不同的方法 示例代码: require 'selenium-webdriver' driver = Selenium::WebDriver.for :firefox driver.navigate.to 'http://www.google.com' element = driver.find_element(:id, 'gbqfba') 那我已经试过了

我试图用Ruby中的SeleniumWebDriver 2.4模拟鼠标移动

如果我运行测试,是否应该看到鼠标在屏幕上移动?我很困惑

我试过很多不同的方法 示例代码:

require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to 'http://www.google.com'
element = driver.find_element(:id, 'gbqfba')
那我已经试过了

driver.action.move_to(element).perform
driver.mouse.move_to(element)
还有瓦蒂尔的悬停法

到目前为止,我发现最好的方式是瓦蒂尔的火灾事件“onmouseover” 但仍然没有移动鼠标:)

在搜索了某某和其他地方之后,我似乎找不到任何可以在WebDriver中移动鼠标的东西


发生什么事了?是否可以在屏幕上实际移动鼠标光标(当webdriver浏览器窗口处于视图中时)

答案是您将看不到鼠标移动。Selenium在内部与页面交互,这意味着它不会使用桌面鼠标

如果您担心它不起作用,那么可能是因为
driver.action.move\u to(element.perform)
is而使用了错误的元素