Skip to content

Selenium Parallel tests execution

Jakub Raczek edited this page Sep 30, 2025 · 20 revisions

The framework is specifically designed to support parallel test execution. It allows tests to run in parallel within a single browser instance, depending on the capabilities of the chosen unit testing framework. Additionally, it supports running tests across multiple browsers simultaneously, for example by using Selenium Grid.

With Ocaramba.Tests.NUnit

To enable parallel execution of test fixtures, you need to add the ParallelScope.Fixtures attribute to your test classes. This attribute allows fixtures to run concurrently with one another. For parallel execution to take effect, you must have at least two distinct test classes marked with ParallelScope.Fixtures. Additionally, the tests within each class must be independent and must not interfere with each other when executed in parallel.

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 also methods 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