我如何在Watir中模拟私人浏览体验? (selenium)

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

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

谢谢

对于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的解决方案。 它似乎工作(至少主菜单说它是私人浏览)。

适用于Chrome

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