简体   繁体   English

NoMethodError-Watir :: Time:Class的未定义方法“ now”

[英]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.rbcurrent_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.

相关问题 NoMethodError:Time:Class的未定义方法`zone&#39; - NoMethodError: undefined method `zone' for Time:Class 未定义的方法...用于类(NoMethodError) - undefined method … for class (NoMethodError) Rails NoMethodError(Time:Class的未定义方法“ something”):不太重要的错误 - Rails NoMethodError (undefined method `something ' for Time:Class): not so trivial error 清除输入字段:#的未定义方法“ clear” <Watir::Input:XYZ> (NoMethodError) - Clear input field: undefined method `clear' for #<Watir::Input:XYZ> (NoMethodError) 红宝石类未定义方法(NoMethodError) - ruby class undefined method (NoMethodError) Ruby NoMethodError(未定义方法 ''...' for '...:Class' - Ruby NoMethodError (undefined method ''…' for '…:Class' 来自类中Private方法的NoMethodError(未定义方法) - NoMethodError (undefined method) from Private method in class 未定义方法'访问'#<Class:XYZ>(NoMethodError)[rspec] - Undefined method 'visit' for #<Class:XYZ> (NoMethodError) [rspec] IO:Class的Ruby未定义方法“写入”(NoMethodError) - Ruby undefined method `write' for IO:Class (NoMethodError) NoMethodError:BigDecimal 的未定义方法“新”:Class - NoMethodError: undefined method `new' for BigDecimal:Class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM