The solution I'm testing saves the login so when I open a new browser the login is already done and my tests fail. browser.Dispose() doesn't work in this case. It would be better to test in incognito mode and I noticed that changing the driver's configuration is the easiest way to do it but I'm not sure how I can change it since I'm also using coypu.
This is how I create a new browser, I'm not sure how I can change this to include the running in incognito mode.
public static BrowserSession BrowserBackEnd;
public static BrowserSession Instance
{
get
{
if (BrowserBackEnd == null)
{
CreateNewBrowserSession();
}
return BrowserBackEnd;
}
private set { }
}
private static void CreateNewBrowserSession()
{
var sessionConfigurationChrome = new SessionConfiguration
{
Browser = Coypu.Drivers.Browser.Chrome,
AppHost = "sitehere.com",
Timeout = TimeSpan.FromSeconds(20),
RetryInterval = TimeSpan.FromSeconds(0.1)
};
BrowserBackEnd = new BrowserSession(sessionConfigurationChrome);
}
The incognito argument causes the browser to launch directly in incognito mode.
// Causes the browser to launch directly in incognito mode. const char kIncognito[] = "incognito";
To execute the tests in incognito mode of google-chrome you need to add the argument --incognito
as follows:
var options = new ChromeOptions();
options.AddArgument("--incognito");
You can use --incognito
flag
ChromeOptions options = new ChromeOptions();
options.AddArguments("--incognito");
IWebDriver driver = new ChromeDriver("C://",options);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.