Selenium, FluentAutomation & NUnit - How do I switch browsers for each TestCase? Selenium, FluentAutomation & NUnit - How do I switch browsers for each TestCase? selenium selenium

Selenium, FluentAutomation & NUnit - How do I switch browsers for each TestCase?


Dev branch: The latest bits in the Dev branch play nicely with NUnit's parameterized test cases in my experience.

Just move the Bootstrap call inside the testcase itself and be sure that you manually call I.Dispose() at the end. This allows for proper browser creation when run in this context.

Here is an example that you should be able to copy/paste and run, if you pull latest from GitHub on the dev branch.

    [TestCase(FluentAutomation.SeleniumWebDriver.Browser.InternetExplorer)]    [TestCase(FluentAutomation.SeleniumWebDriver.Browser.Chrome)]    public void CartTest(FluentAutomation.SeleniumWebDriver.Browser browser)    {        FluentAutomation.SeleniumWebDriver.Bootstrap(browser);        I.Open("http://automation.apphb.com/forms");        I.Select("Motorcycles").From(".liveExample tr select:eq(0)"); // Select by value/text        I.Select(2).From(".liveExample tr select:eq(1)"); // Select by index        I.Enter(6).In(".liveExample td.quantity input:eq(0)");        I.Expect.Text("$197.70").In(".liveExample tr span:eq(1)");        // add second product        I.Click(".liveExample button:eq(0)");        I.Select(1).From(".liveExample tr select:eq(2)");        I.Select(4).From(".liveExample tr select:eq(3)");        I.Enter(8).In(".liveExample td.quantity input:eq(1)");        I.Expect.Text("$788.64").In(".liveExample tr span:eq(3)");        // validate totals        I.Expect.Text("$986.34").In("p.grandTotal span");        // remove first product        I.Click(".liveExample a:eq(0)");        // validate new total        I.WaitUntil(() => I.Expect.Text("$788.64").In("p.grandTotal span"));        I.Dispose();    }

It should find its way to NuGet in the next release which I'm hoping happens this week.

NuGet v2.0: Currently only one call to Bootstrap is supported per test. In v1 we had built-in support for running the same test against all the browsers supported by a provider but found that users preferred to split it out into multiple tests.

The way I manage it with v2 is to have a 'Base' TestClass that has the TestMethods in it. I then extend that once per browser I want to target, and override the constructor to call the appropriate Bootstrap method.

A bit more verbose but very easy to manage.