edm
edm

Reputation: 53

Errors thrown up when moving from watir 5.0 to watir 6.0

This is my gemfile:

    source 'https://rubygems.org'

gem 'watir', '~> 6.0', '>= 6.0.0'
gem 'watir-scroll'
gem 'cucumber', '~> 2.4', '>= 2.0.0'
gem 'rspec'
gem 'page-object'
gem 'require_all'
gem 'nokogiri', '~> 1.6.8', '>= 1.6.8.1'
gem 'webdriver-user-agent', '~> 7.1'
gem 'headless'
gem 'bundle', '~> 0.0.1'
gem 'appium_lib'
gem 'rake'
gem 'test-unit'

This is the output of bundle update

Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 12.1.0
Using awesome_print 1.8.0
Using json 2.1.0 (was 1.8.6)
Using mini_portile2 2.1.0
Using ffi 1.9.18 (x86-mingw32)
Using rubyzip 1.2.1
Using tomlrb 1.2.5
Using builder 3.2.3
Using bundler 1.15.4
Using gherkin 4.1.3
Using cucumber-wire 0.0.1
Using diff-lcs 1.3
Using multi_json 1.12.2
Using multi_test 0.1.2
Using i18n 0.8.6
Using yml_reader 0.7
Using facets 3.1.0
Using headless 2.3.1
Using power_assert 1.1.0
Using psych 2.2.4
Using require_all 1.4.0
Using rspec-support 3.6.0
Using nokogiri 1.6.8.1 (x86-mingw32)
Using childprocess 0.8.0
Using bundle 0.0.1
Using cucumber-core 1.5.0
Using faker 1.8.4
Using test-unit 3.2.6
Using rspec-core 3.6.0
Using rspec-expectations 3.6.0
Using rspec-mocks 3.6.0
Using selenium-webdriver 3.6.0 (was 2.53.4)
Using cucumber 2.99.0
Using data_magic 1.2
Using rspec 3.6.0
Using appium_lib 9.6.1 (was 9.0.0)
Using watir 6.8.4 (was 5.0.0)
Using webdriver-user-agent 7.4
Using page_navigation 0.10
Using watir-scroll 0.3.0 (was 0.2.0)
Using page-object 2.2.4 (was 1.2.2)
Bundle updated!

This is the output from Rubymine when executing my gherkin scenario:

D:\<redacted>\Ruby22\bin\ruby.exe -EUTF-8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) D:\<redacted>\Ruby22\bin/cucumber D:/dev/features/feature_files/hbf/category.feature --format Teamcity::Cucumber::Formatter --expand --name "^select resident\, select from dropdown\, verify most popular is displayed$" --color -r features
Testing started at 8:34 AM ...
undefined method `browser_name' for :chrome:Symbol (NoMethodError)
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/watir-6.8.4/lib/watir/capabilities.rb:12:in `initialize'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/watir-6.8.4/lib/watir/browser.rb:47:in `new'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/watir-6.8.4/lib/watir/browser.rb:47:in `initialize'
D:/dev/features/support/hooks.rb:97:in `new'
D:/dev/features/support/hooks.rb:97:in `<top (required)>'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/runtime/support_code.rb:83:in `each'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/runtime.rb:61:in `run!'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/lib/cucumber/cli/main.rb:32:in `execute!'
D:/<redacted>/Ruby22/lib/ruby/gems/2.2.0/gems/cucumber-2.99.0/bin/cucumber:8:in `<top (required)>'
D:/<redacted>/Ruby22/bin/cucumber:23:in `load'
D:/<redacted>/Ruby22/bin/cucumber:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
2017-09-29 08:34:39 WARN Selenium [DEPRECATION] :timeout= is deprecated. Use #read_timeout= and #open_timeout= instead.

Process finished with exit code 2

Just to recap, my scenario works with no errors with Watir5 but the above errors are returned when watir6.0 is installed. I'm using Rubymine 8.0.3

Please let me know if more information is required.

Please provide assistance to resolve this issue. Thanks a bunch

I believe the following is executed when running the scenario:

client = Selenium::WebDriver::Remote::Http::Default.new
    client.timeout = 360
    client.proxy = Selenium::WebDriver::Proxy.new(:http => "<redacted>")
    browser = Watir::Browser.new(:remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => "#{ENV['BROWSER']}".to_sym, :http_client => client)
    browser.driver.manage.window.maximize

Upvotes: 1

Views: 161

Answers (1)

Justin Ko
Justin Ko

Reputation: 46826

This exception is a bug in the the new Watir::Capabilities - see Issue 661.

Aside from waiting for a bug fix to be released, in the short-term, you can use a Remote::Capabilities class instead of a Symbol. In other words, switch:

browser = Watir::Browser.new(:remote, desired_capabilities: :chrome)

to

caps = Selenium::WebDriver::Remote::Capabilities.chrome
browser = Watir::Browser.new(:remote, desired_capabilities: caps)

Upvotes: 1

Related Questions