我正在使用Ruby / Cucumber / Capybara / Chromedriver运行自动化测试,但是在运行简单的测试场景时出现错误。我试图通过更新Ruby,Capybara,Cucumber,Chromdriver和Chrome的版本来解决问题。我需要你的帮助。以下是详细信息:
尝试: 访问“http://www.google.com”
获得: 警告:格式化程序Teamcity :: Cucumber :: Formatter正在使用已弃用的格式化程序API,该API将在Cucumber的v4.0中删除。
2018-04-16 14:32:43 WARN Selenium [DEPRECATION]:不推荐使用args或:开关。请改用Selenium :: WebDriver :: Chrome :: Options#add_argument。
Net :: ReadTimeout:Net :: ReadTimeout ./features/step_definitions/common_steps.rb:46:in`/ ^ testing $ /'
Chrome版本:65.0.3325.181 Chrome驱动程序:2.37 黄瓜:3.1.0 水豚:3.0.1 红宝石:2.2.6
当我从env.rb文件中删除“--disable-extensions”时,如下所示它工作正常..
Capybara :: Selenium :: Driver.new(app,:browser =>:chrome,:switches =>%w [ - disable-extensions --disable-web-security --start-maximized])
答案 0 :(得分:0)
Capybara::Selenium::Driver.new(
app,browser: :chrome,
desired_capabilities: {
'chromeOptions' => {
'useAutomationExtension' => false,
'args' => ['--disable-web-security', '--start-maximized', '--disable-infobars']
}
}
)

答案 1 :(得分:0)
client = Selenium::WebDriver::Remote::Http::Default.new
client.read_timeout = 120
Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: {args: %w[headless disable-gpu disable-popup-blocking window-size=10_000,1080 log-level=3]}
)
Capybara::Selenium::Driver.new(app,
browser: :chrome,
desired_capabilities: capabilities,
http_client: client)
end