Watir :: Exception :: MissingWayOfFindingObjectException: invalid attribute :: css

I'm sure watir-webdriver had support for the CSS selector, but it looks like it is gone:

$ 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>' 

Environment: Mac OS X 10.7.2, Firefox 9.0.1.

Am I doing something wrong?

+2
source share
2 answers

watir-webdriver currently only supports this if you use the Browser # element

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

We could add support for other element methods, but we would need to find a processing method, for example.

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

Funny enough, I can still get around a lot of limitations or missing functionality that are not exposed to the VAI direct JS call, for example

 browser.execute_script('jQuery(\'div#td%s div a\').trigger(\'click\')' % reagent_id) 

As I said, in some cases this is the only way for me. It would be great to have tighter integration in the DOM.

+3
source

Source: https://habr.com/ru/post/1414926/


All Articles