在Mac 10.9上,我的watir-webdriver脚本适用于Chrome和Firefox,但使用Safari时我无法右键单击或双击。尝试双击或右键单击会出现此错误:
按钮可用?真正 /Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/safari/bridge.rb:73:in
raw_execute': Unknown command: mouseMoveTo (Selenium::WebDriver::Error::UnknownError) from /Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/bridge.rb:612:in
执行' 来自/Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/bridge.rb:399:inmouseMoveTo' from /Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/mouse.rb:52:in
move_to “ 来自/Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/mouse.rb:62:inmove_if_needed' from /Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/mouse.rb:26:in
context_click “ 来自/Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/action_builder.rb:344:inblock in perform' from /Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/action_builder.rb:343:in
“ 来自/Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/action_builder.rb:343:inperform' from /Users/engineering/.rvm/gems/ruby-1.9.3-p484/gems/watir-webdriver-0.6.8/lib/watir-webdriver/elements/element.rb:165:in
right_click “ 来自tester.rb:10:在''
这是我的代码。在最后一行,如果我将右键单击方法改为左键单击,它将点击“我感觉很幸运”按钮。有谁知道这个错误发生的原因是什么?我刚刚开始使用Watir。我按照以下步骤从这里获得了使用Safari的watir-webdriver:www.watirwebdriver.com/safari /
require 'watir-webdriver'
b = Watir::Browser.new :safari
b.goto "http://google.ca"
puts "button available? #{b.button(:id => 'gbqfba').exists?}"
b.button(id:'gbqfbb').span(text:"I'm Feeling Lucky").wait_until_present
b.button(id:'gbqfbb').span(text:"I'm Feeling Lucky").right_click
答案 0 :(得分:0)
很抱歉没有添加评论(暂时还没有代表),所以不要将此视为答案。但是你有没有尝试在范围中添加一个id并试图通过它而不是文本来选择它? select from menu after right click watir-webdriver似乎也遇到了右键单击的问题,并通过使用id来选择元素来解决它