配置spec_helper文件以使默认驱动程序在Chrome中打开隐身窗口(Configure the spec_helper file to have the default driver open an incognito window in Chrome)
我被困在试图找出如何让我的默认驱动程序打开Chrome与隐身窗口。
Capybara.default_driver = :selenium_chrome是我目前的默认驱动程序。
如何添加告诉驱动程序始终打开隐身窗口的选项?
I am stuck trying to figure out how to get my default driver to open Chrome with an incognito window.
Capybara.default_driver = :selenium_chrome is what I currently have for my default driver.
How can I add the option that tells the driver to always open an incognito window?
最满意答案
您需要注册您自己的驱动程序,以您想要的方式配置Chrome
Capybara.register_driver :incognito_chrome do |app| browser_options = ::Selenium::WebDriver::Chrome::Options.new browser_options.args << '--incognito' Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options) end然后将其设置为您的默认驱动程序
Capybara.default_driver = :incognito_chromeYou need to register your own driver which configures Chrome the way you want
Capybara.register_driver :incognito_chrome do |app| browser_options = ::Selenium::WebDriver::Chrome::Options.new browser_options.args << '--incognito' Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options) endand then set that as your default driver
Capybara.default_driver = :incognito_chrome更多推荐
发布评论