Reputation: 23
I am suddenly getting an error when initializing a Watir browser. Using current versions of watir-rails and selenium-webdriver gems.
When initializing a chrome headless browser:
browser = Watir::Browser.new :chrome, args: %w[--headless --no-sandbox --disable-dev-shm-usage --disable-gpu --remote-debugging-port=9222]
I get the following error that seems to be caused by a discrepancy with Selenium's expected arguments:
# /usr/local/bundle/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/driver.rb:319:in `create_bridge'
# /usr/local/bundle/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/driver.rb:74:in `initialize'
# /usr/local/bundle/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/driver.rb:47:in `new'
# /usr/local/bundle/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/driver.rb:47:in `for'
# /usr/local/bundle/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver.rb:89:in `for'
# /usr/local/bundle/gems/watir-6.19.1/lib/watir/browser.rb:46:in `initialize'
# /usr/local/bundle/gems/watir-rails-2.2.3/lib/watir/rails/browser.rb:11:in `initialize'
# ./app/services/watir_scraper.rb:11:in `new'
# ./app/services/watir_scraper.rb:11:in `create_browser'
# ./app/services/watir_scraper.rb:5:in `browser'
# ./app/services/state_credential_service/oh/lookup/ohio_elicense_center.rb:38:in `search_for_license'
# ./app/services/state_credential_service/oh/credential_lookup.rb:7:in `block in lookup'
# ./app/services/state_credential_service/oh/credential_lookup.rb:5:in `each'
# ./app/services/state_credential_service/oh/credential_lookup.rb:5:in `lookup'
# ./spec/support/shared_examples/state_credential_lookup_service.rb:32:in `block (4 levels) in <top (required)>'
# /usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# ArgumentError:
# unknown keyword: :desired_capabilities
# /usr/local/bundle/gems/selenium-webdriver-4.6.1/lib/selenium/webdriver/common/driver.rb:319:in `create_bridge'
2023-01-03 18:11:30 WARN Watir [DEPRECATION] ["args_keyword", "capabilities"] :args to initialize Browser is deprecated. Use :args inside Hash with :options key instead; see explanation for this deprecation: http://watir.com/guides/capabilities.html.
As per the warning at the bottom and this SO post, watir selenium: unrecognized arguments for Browser constructor, I have attempted changing the initialization:
BROWSER_OPTIONS = %w[--headless --no-sandbox --disable-dev-shm-usage --disable-gpu --remote-debugging-port=9222]
browser = Watir::Browser.new :chrome, options: {args: BROWSER_OPTIONS}
However I am getting the same error (without the deprecation warning)
Upvotes: 2
Views: 480
Reputation: 4194
The issue is that you need Watir 7 to work with Selenium 4. Please upgrade to the latest version of Watir and it will work.
Upvotes: 1