Currently, openGoogle() does get called for each test case with the correct parameters. The problem is that setBrowser does not appear to be working properly. It does set the first time and completes the test successfully. However, when openGoogle() gets invoked for the second time it continues to use the first browser instead of using the new browser specified.
using NFramework = NUnit.Framework; ...
[NFramework.TestFixture] public class SampleTest : FluentAutomation.FluentTest { string path; private Action<TinyIoCContainer> currentRegistration; public TestContext TestContext { get; set; } [NFramework.SetUp] public void Init() { FluentAutomation.Settings.ScreenshotOnFailedExpect = true; FluentAutomation.Settings.ScreenshotOnFailedAction = true; FluentAutomation.Settings.DefaultWaitTimeout = TimeSpan.FromSeconds(1); FluentAutomation.Settings.DefaultWaitUntilTimeout = TimeSpan.FromSeconds(30); FluentAutomation.Settings.MinimizeAllWindowsOnTestStart = false; FluentAutomation.Settings.ScreenshotPath = path = "C:\\ScreenShots"; } [NFramework.Test] [NFramework.TestCase(SeleniumWebDriver.Browser.Firefox)] [NFramework.TestCase(SeleniumWebDriver.Browser.InternetExplorer)] public void openGoogle(SeleniumWebDriver.Browser browser) { setBrowser(browser); I.Open("http://www.google.com/"); I.WaitUntil(() => I.Expect.Exists("body")); I.Enter("Unit Testing").In("input[name=q]"); I.TakeScreenshot(browser + "EnterText"); I.Click("button[name=btnG]"); I.WaitUntil(() => I.Expect.Exists(".mw")); I.TakeScreenshot(browser + "ClickSearch"); } public SampleTest() { currentRegistration = FluentAutomation.Settings.Registration; } private void setBrowser(SeleniumWebDriver.Browser browser) { switch (browser) { case SeleniumWebDriver.Browser.InternetExplorer: case SeleniumWebDriver.Browser.Firefox: FluentAutomation.SeleniumWebDriver.Bootstrap(browser); break; } } }
Note: Doing it this way below DOES work correctly - opening a separate browser for each test.
public class SampleTest : FluentAutomation.FluentTest { string path; private Action currentRegistration; public TestContext TestContext { get; set; }
private void ie() { FluentAutomation.SeleniumWebDriver.Bootstrap(FluentAutomation.SeleniumWebDriver.Browser.InternetExplorer); } private void ff() { >FluentAutomation.SeleniumWebDriver.Bootstrap(FluentAutomation.SeleniumWebDriver.Browser.Firefox); } public SampleTest() { //ff FluentAutomation.SeleniumWebDriver.Bootstrap(); currentRegistration = FluentAutomation.Settings.Registration; } [TestInitialize] public void Initialize() { FluentAutomation.Settings.ScreenshotOnFailedExpect = true; FluentAutomation.Settings.ScreenshotOnFailedAction = true; FluentAutomation.Settings.DefaultWaitTimeout = TimeSpan.FromSeconds(1); FluentAutomation.Settings.DefaultWaitUntilTimeout = TimeSpan.FromSeconds(30); FluentAutomation.Settings.MinimizeAllWindowsOnTestStart = false; path = TestContext.TestResultsDirectory; FluentAutomation.Settings.ScreenshotPath = path; } [TestMethod] public void OpenGoogleIE() { ie(); openGoogle("IE"); } [TestMethod] public void OpenGoogleFF() { ff(); openGoogle("FF"); } private void openGoogle(string browser) { I.Open("http://www.google.com/"); I.WaitUntil(() => I.Expect.Exists("body")); I.Enter("Unit Testing").In("input[name=q]"); I.TakeScreenshot(browser + "EnterText"); I.Click("button[name=btnG]"); I.WaitUntil(() => I.Expect.Exists(".mw")); I.TakeScreenshot(browser + "ClickSearch"); } }