I want to test my test cases in private window or incognito window.
How to do the same in various browsers:
In chrome you can try using -incognito
command line switch in options, not sure if there will be a problem with automation extension but worth a try.
ChromeOptions options = new ChromeOptions();
options.addArguments("incognito");
For FireFox, a special flag in the profile can be used for the purpose
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.private.browsing.autostart",true);
For IE
setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
I was able to run remote IE in private mode only after following updates:
InternetExplorerOptions options = new InternetExplorerOptions()
.ignoreZoomSettings()
.useCreateProcessApiToLaunchIe()
.addCommandSwitches("-private");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("se:ieOptions", options);
return new RemoteWebDriver(url, capabilities);
All of above didn't work for RemoteWebDriver.
public class gettext {
static WebDriver driver= null;
public static void main(String args[]) throws InterruptedException {
//for private window
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions option = new ChromeOptions();
option.addArguments("incognito");
capabilities.setCapability(ChromeOptions.CAPABILITY,option);
System.setProperty("webdriver.chrome.driver", "D:\\Tools\\chromedriver.exe");
driver= new ChromeDriver(capabilities);
String url = "https://www.google.com/";
driver.manage().window().maximize();
driver.get(url);
driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
gettextdata();
}
}