0

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);
    }
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
MPereira
  • 113
  • 1
  • 8

2 Answers2

1

incognito

The incognito argument causes the browser to launch directly in incognito mode.

  • Defination:

    // Causes the browser to launch directly in incognito mode.
    const char kIncognito[]                     = "incognito";
    

To execute the tests in incognito mode of you need to add the argument --incognito as follows:

var options = new ChromeOptions();
options.AddArgument("--incognito");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

You can use --incognito flag

ChromeOptions options = new ChromeOptions();
options.AddArguments("--incognito");
IWebDriver driver = new ChromeDriver("C://",options);
Swapnil Soni
  • 965
  • 1
  • 10
  • 26