In this Blog, we are
going to learn how we can execute Selenium Automation Test in Incognito (Private)
Mode for Chrome Browser.
Before Going Further
Let's Understand What is Incognito (Private) Mode.
Incognito
mode is a setting in our web browser that prevents Internet browsing history, cookies and site data, or information entered
in forms from being stored. Incognito mode deletes this data as soon as we
close the web browser.
There are two main ways
to execute our selenium Test in Incognito Mode for Chrome Browser.
First Method
v Right Click on Google Chrome and Select Properties.
v In the “Target’ field add an –incognito to the end of the program path.
v Our incognito browser is now ready for
execution. Now, whenever we execute our automation Scripts it will automatically
execute in incognito mode.
Second Method
Using Chrome driver Capabilities
and Chrome Options to
addArguments –incognito in the code.
addArguments –incognito in the code.
Please refer below code snippet
for complete Details.
After executing the Code, Result will be like:
Do we still need to set Desired Capability. Can same functionality achieve with only chromeOptions.
Reply---------------------
ChromeOptions options=new ChromeOptions();
options.addArguments("--incognito");
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
WebDriver driver=new ChromeDriver(options);
driver.get("http://www.google.com")