:driver_opts 已弃用。将 :service 与 Selenium::WebDriver::Service 的实例一起使用
:driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
Screenshot error, but continue to execute.
wrong number of arguments (given 0, expected 1)
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
visit in hook, after scenario +1s, @1s
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
我一直在使用下面的代码片段来启动与旧 'selenium-webdriver' v3.6.0 的会话,但出现了上述错误:
6月23日更新
if Capybara.default_driver == :selenium
Capybara.register_driver :selenium do |app|
# In the block, we build up an `options` hash to pass to
# Capybara::Selenium::Driver.new(app, options)
# which in turn calls
# Selenium::WebDriver.for(options[:browser], options)
browser = Configuration.fetch('browser.type', :firefox)
options = {
browser: browser, # chrome
}
if Configuration.fetch('options.webdriver.use_hub', false)
{...}
elsif browser == :firefox
{...}
elsif browser == :chrome
chrome_logpath = "../chromedriver.log"
options[:service] = ::Selenium::WebDriver::Service.chrome(
args: {
verbose: true,
log_path: chrome_logpath,
}
)
chrome_options = Selenium::WebDriver::Chrome::Options.new
chrome_options.add_argument("user-agent='QA Test'")
chrome_options.add_option('w3c',false)
options[:options] = chrome_options
end
Capybara::Selenium::Driver.new(app, options)
end
end
将 gem 升级到 v3.142.0 后,我得到了那个错误。追溯到 https://github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES 中的 Selenium Webdriver Changelog 然后我发现了以下描述,这可能会破坏当前代码
3.141.592 (2019-04-18)
Chrome:
Added support for instantiating service class directly and moved all driver executable configuration there (command-line arguments, port, etc.)
Passing driver_opts, driver_path and port to driver initializer is now deprecated
so use Selenium::WebDriver::Service.chrome instead,
which allows to customize executable behavior in similar way.
Once initialized, this object can be passed as :service keyword
during driver initialization.
* Deprecated Chrome.driver_path= in favor of Service::Chrome.driver_path=
谷歌搜索了一段时间,我发现了一些结果和解决方法,比如使用 'webdriver' gem,但我不太喜欢它。
想知道我是否可以更改上面的代码片段以适应 selenium-webdriver ver 3.142.0 及更高版本?我现在使用的是 Capybara v3.18.0。
谢谢大家,
这不是错误,而是弃用警告。它告诉您需要在 selenium-webdriver v4.0 发布之前更改您的代码。如果你觉得你今天必须更新你的代码,那就是
elsif browser == :chrome
options[:service] = ::Selenium::WebDriver::Service.chrome(
args: {
verbose: true,
log_path: "../chromedriver.log",
}
)
chrome_options = Selenium::WebDriver::Chrome::Options.new
# add user agent to that class options
chrome_options.add_argument("user-agent='QA Test'")
options[:options] = chrome_options
end
您展示的其他内容
Screenshot error, but continue to execute.
wrong number of arguments (given 0, expected 1)
有所不同,并非来自您显示的任何代码。
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
Screenshot error, but continue to execute.
wrong number of arguments (given 0, expected 1)
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
visit in hook, after scenario +1s, @1s
2019-06-19 15:44:43 WARN Selenium [DEPRECATION] :driver_opts is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
我一直在使用下面的代码片段来启动与旧 'selenium-webdriver' v3.6.0 的会话,但出现了上述错误:
6月23日更新
if Capybara.default_driver == :selenium
Capybara.register_driver :selenium do |app|
# In the block, we build up an `options` hash to pass to
# Capybara::Selenium::Driver.new(app, options)
# which in turn calls
# Selenium::WebDriver.for(options[:browser], options)
browser = Configuration.fetch('browser.type', :firefox)
options = {
browser: browser, # chrome
}
if Configuration.fetch('options.webdriver.use_hub', false)
{...}
elsif browser == :firefox
{...}
elsif browser == :chrome
chrome_logpath = "../chromedriver.log"
options[:service] = ::Selenium::WebDriver::Service.chrome(
args: {
verbose: true,
log_path: chrome_logpath,
}
)
chrome_options = Selenium::WebDriver::Chrome::Options.new
chrome_options.add_argument("user-agent='QA Test'")
chrome_options.add_option('w3c',false)
options[:options] = chrome_options
end
Capybara::Selenium::Driver.new(app, options)
end
end
将 gem 升级到 v3.142.0 后,我得到了那个错误。追溯到 https://github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES 中的 Selenium Webdriver Changelog 然后我发现了以下描述,这可能会破坏当前代码 3.141.592 (2019-04-18)
Chrome:
Added support for instantiating service class directly and moved all driver executable configuration there (command-line arguments, port, etc.)
Passing driver_opts, driver_path and port to driver initializer is now deprecated
so use Selenium::WebDriver::Service.chrome instead,
which allows to customize executable behavior in similar way.
Once initialized, this object can be passed as :service keyword
during driver initialization.
* Deprecated Chrome.driver_path= in favor of Service::Chrome.driver_path=
谷歌搜索了一段时间,我发现了一些结果和解决方法,比如使用 'webdriver' gem,但我不太喜欢它。
想知道我是否可以更改上面的代码片段以适应 selenium-webdriver ver 3.142.0 及更高版本?我现在使用的是 Capybara v3.18.0。
谢谢大家,
这不是错误,而是弃用警告。它告诉您需要在 selenium-webdriver v4.0 发布之前更改您的代码。如果你觉得你今天必须更新你的代码,那就是
elsif browser == :chrome
options[:service] = ::Selenium::WebDriver::Service.chrome(
args: {
verbose: true,
log_path: "../chromedriver.log",
}
)
chrome_options = Selenium::WebDriver::Chrome::Options.new
# add user agent to that class options
chrome_options.add_argument("user-agent='QA Test'")
options[:options] = chrome_options
end
您展示的其他内容
Screenshot error, but continue to execute.
wrong number of arguments (given 0, expected 1)
有所不同,并非来自您显示的任何代码。