如果机器无人值守,ruby watir browser.send_keys会在60秒后超时

时间:2018-05-09 02:51:55

标签: ruby windows focus watir sendkeys

我正在使用send_keys,我必须按Enter键

@ie.element(:css, "#accountSwitcherSelect.dijitDownArrowButton").send_keys :enter

使另一个对象可以切换帐户

@ie.div(:id => "accountSwitcherSelect_dropdown").table(:id => "accountSwitcherSelect_menu")

这里是踢球者,如果我在那里,它的效果非常好,并且浏览器在前景中对焦。

但是,如果我也是 a)锁定Windows操作系统屏幕,或 b)正在远程桌面上工作并切换出RDP,或 c)开始从无人值守机器上的计划任务运行ruby脚本 它会看到第一次下拉就好了

puts @ie.element(:css, "#accountSwitcherSelect.dijitDownArrowButton").visible?

但它永远不会 send_keys:输入,永远不会看到" accountSwitcherSelect_menu" 并抛出

  

60秒后超时

错误

watir 6.10.3,ruby 2.2.5,Windows OS,IE 11

- 这里是完整的错误消息,其中第125行是

@ie.element(:css, "#accountSwitcherSelect.dijitDownArrowButton").send_keys :enter
  

C:/ruby225/lib/ruby/gems/2.2.0/gems/rautomation-0.17.0/lib/rautomation/wait_helper.rb:20:在   {_ 1}}阻止了send_keys'           来自C:/ruby225/lib/ruby/gems/2.2.0/gems/rautomation-0.17.0/lib/rautomation/adapter/win_32/window.rb:152:in   wait_until': timed out after 60 seconds (RAutomation::WaitHelper::TimeoutError) from C:/ruby225/lib/ruby/gems/2.2.0/gems/rautomation-0.17.0/lib/rautomation/adapter/win_32/window.rb:153:in send_keys'           来自C:/ruby225/lib/ruby/gems/2.2.0/gems/rautomation-0.17.0/lib/rautomation/window.rb:192:in   each' from C:/ruby225/lib/ruby/gems/2.2.0/gems/rautomation-0.17.0/lib/rautomation/adapter/win_32/window.rb:152:in send_keys'           来自C:/ruby225/lib/ruby/gems/2.2.0/gems/watir-classic-4.3.0/lib/watir-classic/element.rb:124:in   send_keys' from C:/ruby225/lib/ruby/gems/2.2.0/gems/watir-classic-4.3.0/lib/watir-classic/browser.rb:452:in 阻止'           来自DeleteTriggers8.rb:106:send_keys ' from DeleteTriggers8.rb:125:in'

1 个答案:

答案 0 :(得分:0)

谢谢@Rajagopalan浏览器窗口焦点问题似乎是现在已弃用的watir-classic的限制。切换到最新的watir-webdriver解决了这个问题。