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

时间:2022-11-25 19:44:01

Watir is a Selenium-based black-box testing tool that can automate tasks on the browser.

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

I would like to be able to open up a Watir::Browser.new that is in private browsing mode.

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

Thanks

2 个解决方案

#1


2  

For Firefox (I am not sure about the other browsers), you can setup the profile to have private browsing enabled:

对于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

This was the solution from https://github.com/watir/watir-webdriver/issues/95. It seems to work (at least the main menu says it is private browsing).

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

#2


1  

For Chrome

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

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

#1


2  

For Firefox (I am not sure about the other browsers), you can setup the profile to have private browsing enabled:

对于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

This was the solution from https://github.com/watir/watir-webdriver/issues/95. It seems to work (at least the main menu says it is private browsing).

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

#2


1  

For Chrome

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

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