Loading browser only once in Protractor.NET?

I'm new to Protractor.NET and I apologize if this is a layman's question.

I am testing an AngularJs app using Protractor.NET. I have written several test scripts in C #. But for every test that runs, Protractor loads the Browser over and over and closes / terminates it. Can this be avoided? and just load the browser just once and with that instance let my test script run.

Is it possible to achieve?

[TestClass]
public class BaseTest
{

    protected IWebDriver _driver;
    protected NgWebDriver _ngWebDriver;

    [TestInitialize]
    public void Setup()
    {
        var key = ConfigurationManager.AppSettings["key"];
        _driver = new ChromeDriver(key);
        _driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
        _ngWebDriver = new NgWebDriver(_driver);
    }

    [TestCleanup]
    public void Teardown()
    {
        _ngWebDriver.Quit();
    }
}

      

If I comment out the [TestCleanup] method, the browser does not close and new instances are created. I just need to use one instance and run my test cases.

+3


source to share


1 answer


Yes. Just use the [ClassInitialize] and [ClassCleanup] attributes instead of [TestInitialize] and [TestCleanup].



+3


source







All Articles