简体   繁体   中英

How can I run a test in a private IE browser in C#, using Selenium in Visual Studio?

I'm trying to have an automated test run in a private IE browser but the tips I've found so far on here and other sites aren't working for me.

This is my code:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.IE;



namespace Events_Application
{
    [TestClass]

    public class IETests : BaseTest
    {
        #region Constructor

        public IETests()
        {

            WebDriver = new InternetExplorerDriver("--private");


        }
        #endregion

    }
}

As you can see, I'm telling it to look at 'BaseTest' where the test case resides, which runs fine in other browsers, just not in IE because it keeps wanting to sign into my work Microsoft account whenever I run the test (part of the test involves logging into the application which is done via microsoftonline.com).

Any ideas as to how I can get it to open in a private (incognito) window? Do I need a specific NuGet package?

Thanks

That looks similar to another question . Try a single -, just:

WebDriver = new InternetExplorerDriver("-private");

Curious if that does it?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM