Chandra Shekhar Chandra Shekhar - 5 months ago 90
Java Question

How to open web browser in incognito mode using Selenium- Java with Multiple Tabs

I want to open browser window in Incognito mode with multiple tabs using Selenium(Java). Browser should open 3 tabs parallely as soon as it is launched.

Answer

Chrome:

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("incognito");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

Internet Explorer:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true); 
capabilities.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");