当使用父方法定位元素时,watir抛出JavascriptError

时间:2015-01-20 06:31:45

标签: watir watir-webdriver

以Github为例,代码如下:

require 'rubygems'
require 'watir'
require 'watir-webdriver'

b = Watir::Browser.new :firefox

b.goto "https://github.com/about"
puts b.div(:class => "column one-half").present?
puts b.div(:class => "column one-half").parent.text

得到这些输出:

[remote server] https://github.com/about line 68 > Function:17:in `H': a is undefined (Selenium::WebDriver::Error::JavascriptError)
    from [remote server] https://github.com/about line 68 > Function:17:in `anonymous/</<'
    from [remote server] https://github.com/about line 68 > Function:14:in `anonymous/<'
    from [remote server] https://github.com/about line 68 > Function:14:in `anonymous'
    from [remote server] https://github.com/about:68:in `handleEvaluateEvent'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:640:in `raw_execute'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:618:in `execute'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/remote/bridge.rb:339:in `executeScript'
    from my_path/gems/ruby-2.1.5/gems/selenium-webdriver-2.44.0/lib/selenium/webdriver/common/driver.rb:193:in `execute_script'
    from my_path/gems/ruby-2.1.5/gems/watir-webdriver-0.6.11/lib/watir-webdriver/atoms.rb:20:in `execute_atom'
    from my_path/gems/ruby-2.1.5/gems/watir-webdriver-0.6.11/lib/watir-webdriver/elements/element.rb:373:in `parent'
    from t.rb:9:in `<main>'
true

尝试其他网站,得到相同的结果,任何人都知道为什么?感谢

0 个答案:

没有答案