Running Chrome Browser in Incognito (Private) Mode using Selenium


Running Chrome Browser in Incognito (Private) Mode using Selenium

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 storedIncognito 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. 




    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.

Please refer below code snippet for complete Details.


After executing the Code, Result will be like:




Happy Learning J



SHARE THIS

Author:

My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
Anonymous
December 8, 2018 at 10:59 AM

Do we still need to set Desired Capability. Can same functionality achieve with only chromeOptions.
---------------------
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")

Reply
avatar