mercredi 1 avril 2015

Reuse browser instance across multiple tests in same class using FluentAutomation with MSTests

I am using FluentAutomation with MSTests. I need to be able to reuse the browser instance across multiple test methods in the same class. For example, the constructor or TestInitialize method will login to a url, then all the subsequent Test methods in the class will need to use the same logged in session and browser instance.


Tried using the FluentSession.EnableStickySession(); but that didn't work, and 2nd method in execution complains that IEDriver is already being used by another process.


Any ideas how to resolve this?


Here's the sample code for the scenario:



[TestClass]
public class DummyTests : FluentTest
{
public DummyTests()
{
SeleniumWebDriver.Bootstrap(SeleniumWebDriver.Browser.InternetExplorer);
I.Open(@"http://google.com");
FluentSession.EnableStickySession();
}

[TestMethod]
public void First()
{
I.Wait(2)
.Enter("NBA").In("input#lst-ib.gsfi")
.Click("button[type='submit']");

}

[TestMethod]
public void Second()
{
I.Wait(2)
.Enter("MLB").In("input#lst-ib.gsfi")
.Click("button[type='submit']");
}
}

Aucun commentaire:

Enregistrer un commentaire