I recently inherited a Ruby test suite which is running watir-webdriver (0.6.4), and I'm in the unfortunate situation where the suite runs just fine on my colleague's machine, but several cases error out on mine. I've tried locking every version of all my gems to exactly what's on his machine to try to solve the compatibility issue, but no dice. The core error seems to be that I get the following exception originating from watir's internal `assert_valid_as_attribute' method:
(Watir::Exception::MissingWayOfFindingObjectException: invalid attribute: :css)
The originating call in my code is:
search_results.selectable_cards_plural.take(assets_selected).each { |assets| assets.fire_event ("onclick") }
search_results{...}.take returns an array of divs.
Has anyone seen this issue before? I've seen two other SO posts mentioning this issue, but neither of them seemed to address my particular issue.
I've included a portion of my gemfile.lock below, in case anyone can easily spot the compatibility issue. I'm running Ruby 2.5.0. And yes, I plan to update tests to run newer gem versions in the near future, but I want to have these legacy regression tests running in the meanwhile.
Selectors mentioned above:
def search_results; @browser.div(:class, 'search-results-grid') end
def selectable_cards_plural; divs(:css => 'div.p-card-hover.p-card-selectable:not(.p-card-selected)') end
The element being selected is: class="p-card-hover p-card-selectable css-g6ribn-StyledCardHover-visible-visible-visible-visible-StyledCardHover erkh22a0"
Environment info: MacOS macOS 10.14.3 (Mojave) Chrome Version 72.0.3626.121 Browser driver: @browser = Watir::Browser.new :chrome, :prefs => chrome_prefs, switches: %w[--window-size=1600,900 --ignore-certificate-errors --disable-popup-blocking --disable-translate]
Stack trace:
Asset Section: Adding # When selecting specific # from search adds assets to section
Failure/Error: search_results.selectable_cards_plural.take(assets_selected).each { |assets| assets.fire_event ("onclick") }
Watir::Exception::MissingWayOfFindingObjectException:
invalid attribute: :css
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:238:in `assert_valid_as_attribute'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:219:in `normalize_selector'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:198:in `block in normalized_selector'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:195:in `each'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:195:in `normalized_selector'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:98:in `find_all_by_multiple'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/locators/element_locator.rb:46:in `locate_all'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/element_collection.rb:96:in `elements'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/element_collection.rb:86:in `to_a'
# /Users/jnguyen/.rvm/gems/ruby-2.5.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/element_collection.rb:29:in `each'
# ./lib/live_editor/assets_le.rb:37:in `take'
# ./lib/live_editor/assets_le.rb:37:in `select_assets'
# ./spec/smoke/live_editor/standard/asset_add_num_spec.rb:23:in `block (3 levels) in <top (required)>'
Gemfile.lock
{...}
commonwatir (4.0.0)
rake (12.3.2)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.2)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
rspec_html_formatter (0.3.1)
activesupport (>= 4.1.4)
rouge (>= 1.6.1)
rspec-core (>= 3.0.3)
selenium-webdriver (2.53.4)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
watir (5.0.0)
commonwatir (~> 4)
watir-webdriver
watir-rspec (2.0.3)
rspec (~> 3.0)
watir (~> 5.0)
watir-scroll (0.1.0)
watir-webdriver
watir-webdriver (0.6.4)
selenium-webdriver (>= 2.18.0)
PLATFORMS
ruby
DEPENDENCIES
{...}
rake
rspec (= 3.5.0)
rspec-core (= 3.5.2)
rspec_html_formatter (~> 0.3.1)
selenium-webdriver (= 2.53.4)
watir (~> 5.0.0)
watir-rspec (= 2.0.3)
watir-scroll (~> 0.1.0)
watir-webdriver (= 0.6.4)
BUNDLED WITH
1.17.3
watir-webdriveris deprecated, you should probably add the environmental info (e.g. browser, OS, browser drivers, etc). - orde:csslocator wouldn't normally be going toassert_valid_as_attribute. - Justin Ko