从watir 5.0移动到watir 6.0

时间:2017-09-29 00:43:29

标签: ruby cucumber watir

这是我的宝石文件:

    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'

这是捆绑更新的输出

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!

这是执行我的小黄瓜场景时Rubymine的输出:

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

回顾一下,我的方案与Watir5没有错误,但安装watir6.0时会返回上述错误。我正在使用Rubymine 8.0.3

如果需要更多信息,请与我们联系。

请提供帮助以解决此问题。非常感谢

我相信在运行场景时会执行以下操作:

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

1 个答案:

答案 0 :(得分:1)

此例外是新Watir::Capabilities中的错误 - 请参阅Issue 661

除了等待发布错误修复程序之外,在短期内,您可以使用Remote::Capabilities类而不是Symbol。换句话说,切换:

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

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