2

Watir 是一个基于 Selenium 的黑盒测试工具,可以在浏览器上自动执行任务。

我希望能够打开一个处于隐私浏览模式的 Watir::Browser.new。

谢谢

4

2 回答 2

2

对于 Firefox(我不确定其他浏览器),您可以将配置文件设置为启用隐私浏览:

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.privatebrowsing.dont_prompt_on_enter'] = true
profile['browser.privatebrowsing.autostart'] = true
b = Watir::Browser.new :firefox, :profile => profile

这是来自https://github.com/watir/watir-webdriver/issues/95的解决方案。它似乎工作(至少主菜单说它是私人浏览)。

于 2012-10-26T14:38:23.753 回答
2

对于铬

browser = Watir::Browser.new :chrome, switches: ['--incognito']

于 2016-12-09T23:51:10.983 回答