Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support providing your own webdriver instance, parallell instances break #160

Open
andrejohansson opened this issue Jan 18, 2016 · 1 comment

Comments

@andrejohansson
Copy link

It's unclear today how the bootstrap method sets up webdrivers, it would be good to be able to provide your own webdriver instance in many cases (newer drivers, custom drivers, parallelll tests).

We have the following setup:

  1. We have some tests
  2. We run nunit 3 because it supports parallell execution
  3. We use browserstack so all our tests are running towards clean instances

We have a base fixture like this:

    [TestFixture("Edge", "12.0", "Windows", "10", "TestData.json")]
    [TestFixture("IE", "11.0", "Windows", "8.1", "TestData.json")]
    [TestFixture("Chrome", "47.0", "Windows", "8.1", "TestData.json")]
    [TestFixture("Firefox", "43.0", "Windows", "8.1", "TestData.json")]
    [Parallelizable(ParallelScope.Fixtures)]
    public class BaseTestFixture : FluentTest
    {
        public string Browser { get; set; }
        public string BrowserVersion { get; set; }
        public string Os { get; set; }
        public string OsVersion { get; set; }
        public string TestDataPath { get; set; }

        public Dictionary<string, object> Capabilities { get; set; }

        public BaseTestFixture(string browser, string browserVersion, string os, string osVersion, string testDataPath)
        {
            Browser = browser;
            BrowserVersion = browserVersion;
            Os = os;
            OsVersion = osVersion;
            TestDataPath = Path.Combine(@".\Data", testDataPath);
        }

        [SetUp]
        public void Init()
        {
            ReadTestData();
            Capabilities = GetCapabilitites();

            SeleniumWebDriver.Bootstrap(
                BrowserStack.Uri,
                Capabilities);
            LogCapabilities();

            // Setup settings
            FluentSettings.Current.ExpectIsAssert = true;

            // Navigate to root page to initialize the provider
            I.Open(new Uri(string.Format(TestHelper.BaseUrl, TestData.customer.domain.Value)));

            // Show session state
            LogCookies();
        }

...

I expected each test having it's own driver using this, but it doesn't seem like it since fluentautomaiton is using the TinyIoCContainer.

Would it be possible to have some initialization like this and for fluentautomation to not use any static state sharing between instances?

SeleniumWebDriver.Bootstrap(new MyDriver(Capabilities));
@andrejohansson
Copy link
Author

Researching a bit further I checked the bootstrap code and there you seems to be generating new driver instances per browser name (depending on which of the bootstap overloads you use).

It would be good to be able to specify your own identifier to support parallell runs. For example: myContextBasedOnParallellRun could be created from a combination of browser, versions, and os to enable parallell remote runs using nunit.

myContextBasedOnParallellRun = "FF-43-WIN-8"; // build this from the nunit attributes or some other parallell metadata instead of just browser name
container.Register<IWebDriver>((c, f) => new EnhancedRemoteWebDriver(BrowserStack.Uri, desiredCapabilities, defaultCommandTimeout), myContextBasedOnParallellRun);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant