0

So I am trying to use a selenium web driver extension on chrome to record a web application test on a chrome browser that is in an incognito mode. How do you run a test on a web application in an incognito mode of google chrome browser?

3 Answers 3

0

you can't record the browser actions with selenium webdriver. This is possible only with Selenium IDE.

So to answer to you question:

You can't make Selenium IDE to open chrome in incognito mode. If you want to achieve a similar functionality in non incognito mode in chrome using Selenoium IDE you can execute javascript to clear the local storage and cookies.

0

While working in a software testing services company, I have experienced such requirement i.e. verifying certain scenarios in chrome incognito mode using Selenium Webdriver.
Please find below code snippet working at my end -

import org.openqa.selenium.WebDriver;                                
import org.openqa.selenium.chrome.ChromeDriver;                      
import org.openqa.selenium.chrome.ChromeOptions;

public class IncognitoTestCase {                                     
    public static void main(String[] args){  
System.setProperty("webdriver.chrome.driver","D:\\your_chrome_directory\\chromedriver.exe");                                            
    ChromeOptions options = new ChromeOptions(); 
    options.addArguments("start-maximized");        
    options.addArguments("--incognito");                          
    WebDriver driver =  new ChromeDriver(options); 
    driver.get("https://accounts.google.com/signin");                     
    }                                                                     
 }
0

Selenium by default runs a clean browser session that gets deleted after test run and that is what incognito mode basically does.

You can, however, force the mode

--incognito: Forces Incognito mode even if user data directory is specified using the --user-data-dir switch.

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--incognito")

driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://google.com')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.