I am automatating tests using Selenium Webdriver 3.0 in Java language. I want to run test in chrome browser in incognito mode. Test runs succesfully but in normal mode not in incognito mode as needed. My code is
@BeforeTest
public void setUp() {
System.setProperty("webdriver.chrome.driver", "C://Selenium driver/chromedriver.exe");
driver = new ChromeDriver();
ChromeOptions options = new ChromeOptions();
options.addArguments("incognito");
driver.manage().window().maximize();
}
@Test
public void testGooglePageTitleInIEBrowser() {
driver.navigate().to("
http://www.google.com");
String strPageTitle = driver.getTitle();
System.out.println("Page title: - "+strPageTitle);
Assert.assertTrue(strPageTitle.equalsIgnoreCase("Google"), "Page title doesn't match");
}
@AfterTest
public void tearDown() {
driver.quit();
}
Browser opens in normal mode.