配置spec

编程入门 行业动态 更新时间:2024-10-28 06:22:41
配置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_chrome

You 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) end

and then set that as your default driver

Capybara.default_driver = :incognito_chrome

更多推荐

本文发布于:2023-08-03 04:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1382920.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:spec

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!