How can I run test in incognito mode using Selenium Python?

How can I run test in incognito mode using Selenium Python?

Hi Ian!

You can perform Selenium automation testing with Python in incognito mode, you need to add the below capabilities in your test script-

desired_caps = {
            'LT:Options': {
                "build": "Python Demo",  # Change your build name here
                "name": "Python Demo Test",  # Change your test name here
                "platformName": "Windows 11",
                "selenium_version": "4.0.0",
                "chromeOptions" : {
                "args" : ["incognito"]  # ChromeOption to start chrome in incognito mode
                }
            },
            "browserName": "Chrome",
            "browserVersion": "98.0",
        }

Here is the sample GitHub repo for the same -