Skip to main content

How to Open Browser in Incognito / InPrivate mode using Selenium / WebDriver

How to Open Chrome Browser in Incognito mode using Selenium / WebDriver ?

        We will use Chrome Drivers Capabilities & ChromeOptions to open Chrome browser in incognito mode. To be precise, we have to use argument --incognito  for ChromeOption as shown in below example-

How to Open Firefox Browser in Incognito / Private mode using Selenium / WebDriver ?

    We will use Firefox Profile  to open Firefox in private mode. To be precise, we will set browser.private.browsing.autostart in firefox profile preference.

How to Open Internet Explorer (IE) Browser in InPrivate mode using Selenium / WebDriver ?  

    We will use IE Driver Capabilities to open IE in InPrivate mode. To be precise we will use FORCE_CREATE_PROCESS capability along with IE_SWITCHES to which parameter would be -private

This is all for now.


  1. Any way you can do this without using "selenium.remote.DesiredCapabilities;" ?

    I'm trying to open in private mode IE in C# code

    And using remote does not work

    1. Is it possible to open browsers in private mode without DesiredCapabilities?
      ==> Yes, it's possible. It is not recommended way, it's just work-around.

      1. Open Browser using webdriver.
      2. Find the body element of the page and then use sendKeys to open new instance of browser in private mode.
      On Windows- for 'Firefox' & 'Edge/IE' - use (Keys.CONTROL, Keys.SHIFT, "p").
      On Windows - for 'Chrome' -use (Keys.CONTROL, Keys.SHIFT, "n").

      Drawback of this method is - You need to take care of switching and controlling new instance of browser using Selenium API.

      Also, key controls that used to open new browser instance in private mode are platfrom dependent. You need to take care of it in your code.


Post a Comment

Popular posts from this blog

History Of Selenium WebDriver

I have assumed that you have already read my past blog entry, Introduction to Selenium WebDriver and here on the quest to find out technical answer of question - what selenium is? Before getting to the answer, I want you to go though the below info-graphics of history of Selenium WebDriver.  History of Selenium Now that you are aware of history, Can you answer what Selenium is? Selenium is set of tools which includes :- Selenium IDE Selenium RC WebDriver Selenium Grid So meaning of Selenium depends upon the context, c iting the man himself - Simon Stewart here - Unfortunately, the Selenium project uses a lot of jargon. Selenium Core is the heart of the original Selenium implementation, and is a set of Javascript scripts that control the browser. This is sometimes referred to as "Selenium" and sometimes as "Core". Selenium RC was the name given to the language bindings for Selenium Core, and is commonly, and confusingly, referred to as just "Selenium"