gpt4 book ai didi

ruby - Windows 上的 Selenium Ruby 绑定(bind)中的 Firefox "Mouseover"问题

转载 作者:数据小太阳 更新时间:2023-10-29 08:12:02 26 4
gpt4 key购买 nike

几天来我一直在为鼠标悬停而苦苦挣扎,在这里发现了几个关于该主题的话题,但都没有帮助。我已经尝试了数十种不同的方法,并且还修改了我的代码以与此处的示例更加同步,尤其是 Dave Haeffner 的建议。当前代码如下所示:

Selenium::WebDriver::Wait.new(timeout: 2).until do
@driver.find_element(link: "ADMIN").displayed?
end
@driver.action.move_to(@driver.find_element(link: "ADMIN")).perform
Selenium::WebDriver::Wait.new(timeout: 2).until do
@driver.find_element(link: "ORGANIZATION").displayed?
end
driver.action.move_to(@driver.find_element(link: "ORGANIZATION")).perform
Selenium::WebDriver::Wait.new(timeout: 2).until do
@driver.find_element(link: "TEAMS").displayed?
end
@driver.find_element(link: "TEAMS").click
end

在 mac 上,这段代码工作正常。然而,在 Windows 上,它会产生:

Failure/Error: @driver.action.move_to(@driver.find_element(link: "ADMIN")).perform
Selenium::WebDriver::Error::InvalidElementStateError:
Cannot perform native interaction: Could not load native events component.

我确定元素访问没问题,因为如果我将第一个鼠标悬停更改为单击操作,效果会很好。

如有任何帮助,我们将不胜感激。

最佳答案

您需要使用 Firefox 版本 31.0.6 。之后的 Firefox 版本不支持 native 事件。如果您需要使用更高版本的 Firefox,那么只需确保您的测试操作都是非 native 的,例如使用 JavascriptExecutor 来创建悬停(而不是依赖 firefox 驱动程序中的 native 事件)。

关于ruby - Windows 上的 Selenium Ruby 绑定(bind)中的 Firefox "Mouseover"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28704923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com