[英]NoMethodError - undefined method `now' for Watir::Time:Class
I get the following error anytime I try to interact with a Watir element. 每当我尝试与Watir元素交互时,都会出现以下错误。
/Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/wait/timer.rb:40:in `current_time': undefined method `now' for Watir::Time:Class (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/wait/timer.rb:6:in `initialize'
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/elements/element.rb:656:in `new'
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/elements/element.rb:656:in `element_call'
from /Library/Ruby/Gems/2.0.0/gems/watir-6.0.1/lib/watir/elements/element.rb:114:in `click'
from fund_cc.rb:8:in `<main>'
Here is my code: 这是我的代码:
require 'watir'
# require 'time'
b = Watir::Browser.new(:chrome)#, :url => "http://localhost:9515")
b.goto "https://www.bankofamerica.com/"
contact_us= b.link(:text, "Contact Us")
contact_us.click
Does anyone know how to resolve this? 有谁知道如何解决这个问题?
I was able to reproduce this behavior. 我能够重现此行为。 You can monkey patch your gem locally by tweaking the
current_time
method in /lib/watir/wait/timer.rb
: 您可以通过调整
/lib/watir/wait/timer.rb
的current_time
方法来猴子本地修补您的gem:
def current_time
::Time.now.to_f # was Time.now.to_f
end
And I'd suggest logging an issue on https://github.com/watir/watir/issues . 我建议在https://github.com/watir/watir/issues上记录问题。
This should be fixed in version 6.0.2. 此问题应在6.0.2版中修复。
From Titus Fortner on the Watir-General mailing list : 从Watir-General邮件列表上的Titus Fortner :
The latest version of Watir attempts to use monotomic time where supported and it looks like we grabbed the wrong Time class for where it is not supported.
Watir的最新版本尝试在支持的情况下使用单调时间,并且似乎在错误的Time类中获取了不支持的时间。
I just updated and pushed the fix to 6.0.2.
我刚刚更新并将修补程序推送到6.0.2。 You should be able to just bundle update now.
您应该现在就可以捆绑更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.