简体   繁体   English

ruby watir-webdriver悬停错误

[英]ruby watir-webdriver hover error

SOLUTION: I downgraded Firefox to version 27.01 and my test is now working again. 解决方案:我将Firefox降级到27.01版,并且我的测试现在又可以正常工作了。 Firefox 28.0 may have some native mouse move problems. Firefox 28.0可能存在一些本机鼠标移动问题。 I was receiving the same error when trying Richard's suggestions below. 尝试以下Richard的建议时,我收到相同的错误。

PROBLEM: I have some basic code that was working last week but now it is not working. 问题:我上周有一些基本的代码可以使用,但是现在不起作用。 Not sure if my Firefox updated and is causing the issue or if this is bad programming and should not be done either way. 不知道我的Firefox是否已更新并引起了问题,或者这是否编程不正确,无论哪种方式都不应这样做。

Here is part of my code. 这是我的代码的一部分。

require 'watir-webdriver'
require 'watir-webdriver/extensions/select_text'
require 'tiny_tds'

browser = Watir::Browser.new :firefox
browser.goto "http://localhost:42706/playerAddEdit/Create"

def self.createNewPlayer(playerInfo, browser)

  printf("%s3 createNewPlayer\n", playerInfo)
  playerInfo.each do |line|
     info = line.split(/,/)

     browser.text_field(:name => 'FName').set info[0]
     browser.text_field(:name => 'LName').set info[1]
     browser.text_field(:name => 'Handicap').set info[2]

     browser.button(:id => 'submit').hover
     browser.button(:id => 'submit').click

     browser.a(:text => "Create New").wait_until_present
     browser.a(:text => "Create New").click
     browser.input(:id => 'FName').wait_until_present
  end
end

The error occurs on the "browser.button(:id => 'submit').hover" line of code, which was working. 该错误发生在正在运行的代码“ browser.button(:id =>'submit')。hover”行上。

The error generated is partially: Selenium::WebDriver::Error::InvalidElementStateError: Cannot perform native interaction: Could not load native events component. 生成的错误部分是:Selenium :: WebDriver :: Error :: InvalidElementStateError:无法执行本地交互:无法加载本地事件组件。

My questions are why would it stop working and is it bad practice to do this? 我的问题是为什么它会停止工作,并且这样做不好? I got in the habit of using hover when I was testing some dropdown's and it helped out. 在测试某些下拉菜单时,我养成了使用悬停的习惯,这很有帮助。 (If I comment out the .hover line everything works fine.) (如果我注释掉.hover行,则一切正常。)

I think you can replace the hover line with this: 我认为您可以将悬停线替换为:

browser.action.move_to(browser.find_element(:id => "submit")).perform

Or replace the two lines with this: 或用以下内容替换两行:

browser.action.move_to(browser.find_element(:id => "submit")).click().perform

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM