Ask a Question

Launch Browser in Incognito/Private Mode

gmathai
Occasional Contributor

Launch Browser in Incognito/Private Mode

Thought of sharing the code in the community for launching browsers in their incognito modes. The function is parameterized such a way to run for the browsers Internet Explorer, Edge, Chrome and Firefox.

Hope it will be useful for more people.

function runIncognitoMode(browserName){

  //var browserName = "firefox" //iexplore,edge,chrome,firefox

  if (Sys.WaitBrowser(browserName).Exists){

    var browser = Sys.Browser(browserName);

    Log.Enabled = false // To disable the warning that might occur during closing of the browser

    browser.Close();

    Log.Enabled = true // enabling the logs back

  }

  if(browserName=="edge"){

    Browsers.Item(btEdge).RunOptions = "-inprivate"

    Delay(3000)

    Browsers.Item(btEdge).Run();

  }else if (browserName=="iexplore"){

    Browsers.Item(btIExplorer).RunOptions = "-private"

    Delay(3000)

    Browsers.Item(btIExplorer).Run();

  }else if (browserName=="chrome"){

    Browsers.Item(btChrome).RunOptions = "-incognito"

    Delay(3000)

    Browsers.Item(btChrome).Run();

  }else if (browserName=="firefox"){

    Browsers.Item(btFirefox).RunOptions = "-private"

    Delay(3000)

    Browsers.Item(btFirefox).Run();

  }

  Sys.Browser(browserName).BrowserWindow(0).Maximize()

}

1 REPLY 1
sonya_m
Community Manager

Re: Launch Browser in Incognito/Private Mode

Thank you @gmathai !


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: