gpt4 book ai didi

css - Watir::Exception::MissingWayOfFindingObjectException:无效属性::css

转载 作者:行者123 更新时间:2023-12-04 20:00:23 25 4
gpt4 key购买 nike

我很确定 watir-webdriver 支持 css 选择器,但看起来它不再存在了:

$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

$ gem -v
1.8.15

$ gem list selenium-webdriver
*** LOCAL GEMS ***
selenium-webdriver (2.17.0)

$ gem list watir-webdriver
*** LOCAL GEMS ***
watir-webdriver (0.4.1)

$ irb
> require "watir-webdriver"
=> true

> browser = Watir::Browser.new :firefox
=> #<Watir::Browser:0x787eb29124fb7658 url="about:blank" title="">

> browser.goto "google.com"
=> "http://www.google.com.mx/"

> browser.a(:css => "a").flash
Watir::Exception::MissingWayOfFindingObjectException: invalid attribute: :css
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/locators/element_locator.rb:228:in `assert_valid_as_attribute'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/locators/element_locator.rb:209:in `normalize_selector'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/locators/element_locator.rb:191:in `block in normalized_selector'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/locators/element_locator.rb:188:in `each'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/locators/element_locator.rb:188:in `normalized_selector'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/locators/element_locator.rb:76:in `find_first_by_multiple'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/locators/element_locator.rb:33:in `locate'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/elements/element.rb:285:in `locate'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/elements/element.rb:259:in `assert_exists'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/elements/element.rb:206:in `style'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.4.1/lib/watir-webdriver/elements/element.rb:103:in `flash'
from (irb):4
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'

环境:Mac OS X 10.7.2、Firefox 9.0.1。

我做错了什么吗?

最佳答案

watir-webdriver 目前只在你使用 Browser#element 时支持这个

 browser.element(:css => "a")

我们可以添加对其他元素方法的支持,但我们必须找到一种方法来处理例如

 browser.a(:css => "div.foo")

关于css - Watir::Exception::MissingWayOfFindingObjectException:无效属性::css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9006223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com