我正在尝试使用 method 将鼠标悬停在公共网站上.hover
,但它似乎仅适用于 Chrome。其他浏览器会产生错误或不显示任何信息。
我尝试了 Watir.fire_event
或.execute_script
内部 Javascript 之类的替代方法,但在 Firefox 和 IE 上都失败了。Watir Classic 给出了相同的结果。
我不明白这是否是关于 Watir 语法、浏览器特定语法或不受支持的浏览器版本的问题。
require "rubygems"
require "watir-webdriver"
BROWSER = Watir::Browser.new :chrome
BROWSER.goto("http://france.meteofrance.com/")
sleep 10 # wait until flash ads are closed
BROWSER.a(:class, "p593500Content").when_present.hover # works, on Chrome only
puts BROWSER.div(:id, "p593500Content").style # position of div after a.hover: left: 249px; top: 223px;
# Chrome - OK, tooltip displayed
# Firefox 7 to 19 - KO: d is undefined in driver_component.js (sometimes l. 7024, or l. 8587)
# IE8, IE9 - KO (maybe OK with IE7): 'unable to locate element, using {:class=>"p593500Content", :tag_name=>"a"}', nothing occurs
Ruby 版本和 Gem 列表:
ruby 1.9.3p392 (2013-02-22) [i386-mingw32]
bigdecimal (1.1.0) rspec-expectations (2.13.0)
builder (3.2.0) rubyzip (0.9.9)
childprocess (0.3.9) s4t-utils (1.0.4)
commonwatir (4.0.0) selenium-webdriver (2.31.0)
cucumber (1.2.3) subexec (0.2.2)
diff-lcs (1.2.1) user-choices (1.1.6.1)
ffi (1.6.0 x86-mingw32) watir (4.0.2 x86-mingw32)
gherkin (2.11.6 x86-mingw32) watir-classic (3.6.0)
hoe (3.5.2) watir-page-helper (1.0.3)
io-console (0.3) watir-webdriver (0.6.2)
json (1.7.7, 1.5.5) websocket (1.0.7)
mini_magick (3.5.0) win32-api (1.4.8 x86-mingw32)
minitest (2.5.1) win32-process (0.7.1)
multi_json (1.7.2) win32screenshot (1.0.8)
nokogiri (1.5.7.rc3 x86-mingw32) windows-api (0.4.2)
rake (0.9.2.2) windows-pr (1.2.2)
rautomation (0.8.0) xml-simple (1.1.2)
rdoc (3.9.5)