How to open incognito/private window with Selenium WD for different browser types?

后端 未结 9 903
感情败类
感情败类 2020-12-05 08:18

I want to test my test cases in private window or incognito window.

How to do the same in various browsers:

9条回答
  •  爱一瞬间的悲伤
    2020-12-05 09:15

    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");
    

    For FireFox, a special flag in the profile can be used for the purpose

    FirefoxProfile firefoxProfile = new FirefoxProfile();    
    firefoxProfile.setPreference("browser.private.browsing.autostart",true);
    

    For IE

    setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
    

提交回复
热议问题