Skip to main content

Hi everyone! I'm working on automated testing for a VR platform and running into an issue with browser session management.

I need to automate user workflow testing on our VR web application, but the testing needs to be done in private mode to ensure clean session states between test runs.

I can successfully capture and interact with web elements when I manually open the browser in incognito mode first, but I'm struggling to programmatically launch the browser in private mode as the initial step of my automation script.

What I'm trying to achieve:

  • Launch Firefox in private
  • Navigate to specific URLs for testing VR session booking flows
  • Perform automated user interactions
  • Ensure no cached data interferes with test scenarios

I've tried using ChromeOptions with --incognito argument but it doesn't seem to work consistently in my test environment (Python 3.9).

Code snippet I'm using:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--incognito")
driver = webdriver.Chrome(options=chrome_options)

Has anyone successfully automated incognito mode launching ? Are there better approaches for ensuring clean browser sessions in automated testing scenarios?

Any guidance would be appreciated! <3

You’re not going to have a good time trying to automate Chrome in Incognito Mode (or Private Mode on Firefox). Instead, I would recommend using regular browser sessions and automating the clearing of the cache/cookies/history.

That being said, you can use the Application: Run action to launch a browser in Incognito Mode using the same argument you showed above.

Edit: See this page for more detail, but I still don’t recommend automating a browser in Incognito Mode.

 


Reply