如何使用Selenium WD打开的隐身/私窗口不同类型的浏览器?
问题描述:
我想测试我的测试案例中的的专用窗口的或 隐身窗口的
I want to test my test cases in private window or incognito window.
如何做同样的在不同的浏览器:
How to do the same in various browsers:
- 火狐(prefered)
- 铬(prefered)
- IE
- Safari浏览器
- 歌剧
如何实现呢?的
How to achieve it?
答
在Chrome浏览器,你可以尝试使用选项-incognito命令行开关,不知道是否会有自动化扩展,但值得一试的一个问题。
In chrome you can try using -incognito command line switch in options, not sure if there will be a problem with automation extension but worth a try.
ChromeOptions options = new ChromeOptions();
options.addArguments("incognito");
有关FF配置文件中的一个特殊标志使用应该这样做。
For FF a special flag in the profile you use should do it
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.private.browsing.autostart",true);
有关IE
setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");