Skip to content

Selenium Parallel tests execution

Jakub Raczek edited this page Apr 25, 2019 · 16 revisions

Our framework supports parallel test execution in one browser at the same time, how to enable it in your test project depends on selected Unit framework:

With Ocaramba.Tests.NUnit

you have to add the attribute to the test classes ParallelScope.Fixtures indicates that fixtures may be run in parallel with one another.

namespace Ocaramba.Tests.NUnit.Tests
{
    using System.Collections.Generic;

    using global::NUnit.Framework;

    using Ocaramba;
    using Ocaramba.Tests.NUnit.DataDriven;
    using Ocaramba.Tests.PageObjects.PageObjects.TheInternet;

    [TestFixture]
    [Parallelizable(ParallelScope.Fixtures)]
    public class HerokuappTestsNUnit : ProjectTestBase
    {
        [Test]
        public void BasicAuthTest()
        {
            var basicAuthPage =
                new InternetPage(this.DriverContext).OpenHomePageWithUserCredentials().GoToBasicAuthPage();

            Verify.That(
                this.DriverContext,
                () =>
                Assert.AreEqual(
                    "Congratulations! You must have the proper credentials.",
                    basicAuthPage.GetCongratulationsInfo));
        }
    }
}
namespace Ocaramba.Tests.NUnit.Tests
{
    using global::NUnit.Framework;

    using Ocaramba.Tests.PageObjects.PageObjects.TheInternet;

    [TestFixture]
    [Parallelizable(ParallelScope.Fixtures)]
    public class JavaScriptAlertsTestsNUnit : ProjectTestBase
    {
        [Test]
        public void ClickJsAlertTest()
        {
            var internetPage = new InternetPage(this.DriverContext).OpenHomePage();
            var jsAlertsPage = internetPage.GoToJavaScriptAlerts();
            jsAlertsPage.OpenJsAlert();
            jsAlertsPage.AcceptAlert();
            Assert.AreEqual("You successfuly clicked an alert", jsAlertsPage.ResultText);
        }
    }
}

More info about NUnit Framework Parallel Test Execution. Please notice that currently only Fixtures may be run in parallel with NUnit 3, more details here.

With Ocaramba.Tests.MsTest

how set parallel test execution depends on Visual Studio version you using or test runner version. More details can be found here MsTest .runsettings .testsettings.

Please notice that Selenium IEDriver doesn't support test execution in parallel.

Running tests in parallel on different browsers at the same time is possible with Selenium Grid or e.g BrowserStack . More details here

Clone this wiki locally