【问题标题】:PhantomJS - Watir Ruby - Watir::Exception::ObjectDisabledException: element present and enabled, but timed out after 30 secondsPhantomJS - Watir Ruby - Watir::Exception::ObjectDisabledException:元素存在并启用,但在 30 秒后超时
【发布时间】:2018-02-16 02:58:58
【问题描述】:

我已经下载了 PhantomJS 并将下面的代码添加到我的脚本中:

Selenium::WebDriver::PhantomJS.path = 'C:\phantomjs-2.1.1-windows\bin\phantomjs.exe'
  @browser = Watir::Browser.new :phantomjs
  @browser.goto "www.samplewebsite.com"

然后我收到以下错误消息:

Watir::Exception::ObjectDisabledException: 元素存在并且 启用,但30秒后超时,等待

"ctl00$ContentPlaceHolder1$Login1$UserName",

:tag_name=>"input"}> 不被禁用

这是 login.rb 文件中的代码:

def browser()
    Watir::Wait.until{@browser.text.include? 'Login'}
end

def credentials()
    @browser.wait
    username = @browser.text_field(name:"ctl00$ContentPlaceHolder1$Login1$UserName").send_keys 'abcd123' #Is this line of code showing the error

    password = @browser.text_field(name:"ctl00$ContentPlaceHolder1$Login1$Password").send_keys'Password'
end

【问题讨论】:

  • 错误提示文本字段被禁用。是吗?您是否尝试过其他浏览器,例如 Chrome?
  • 我已经在其他浏览器上尝试过并且工作正常。只有 Phantomjs 显示此错误。
  • 只想提一下我的项目是页面对象样式,你认为这可能是问题吗?因为登录方法在一个单独的 .rb 文件中。
  • 我已经在单个 .rb 文件上尝试过,上面的问题与页面对象样式有关。有谁知道如何使它工作?谢谢
  • 如果您认为它与页面对象有关,那么显示您的代码的那部分会有所帮助。不过,鉴于它适用于其他浏览器,我很容易认为这是一个 PhantomJS 问题。

标签: ruby phantomjs watir watir-webdriver


【解决方案1】:

我很确定是This Bug。它已在昨天发布的 Watir 6.8.2 中修复。

【讨论】:

  • 我已将 Watir 更新到最新版本,但仍然无法正常工作。
  • 嗯。您可以设置日志记录并提供输出的要点吗? Watir.logger.level = :debug 和 Selenium::WebDriver.logger.level = : info
  • 好的,我会的。谢谢
【解决方案2】:

阅读其他来源的一些帖子,我尝试最大化窗口:@browser.window.maximize 然后它起作用了!是的,这个问题与页面对象无关。关于我没有写的错误消息,我从我的 IDE 日志中复制并粘贴了它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    相关资源
    最近更新 更多