Run chrome browser in inconginto Mode in Selenium
Solution 1:
One other way to launch chrome in incognito mode is to add argument "-incognito" like following:
ChromeOptions options = new ChromeOptions();
options.addArguments("--incognito");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
This solution works for me.
Solution 2:
According to the ChromeDriver wiki you can pass parameters to the executable like this:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--incognito"));
WebDriver driver = new ChromeDriver(capabilities);
So passing the paremeter --incognito should do the trick.
Solution 3:
The code below will open the browser in incognito mode using selinium. Assuming selenium is setup in your eclipse:
public WebDriver chromedriver;
ChromeOptions options = new ChromeOptions();
options.addArguments("--incognito");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver chromedriver=new ChromeDriver(capabilities);