-
Notifications
You must be signed in to change notification settings - Fork 134
Selenium Parallel tests execution
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.
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. The number of tests that can run in parallel from features is also limited by the number of CPU cores available on your machine. More cores allow more tests from features to execute simultaneously.
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.
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.
at the same time is possible with Selenium Grid or e.g BrowserStack . More details here
Using dotnet vstest with /Parallel Flag. The most common way to run tests in parallel is using the /Parallel flag with the dotnet vstest command:
dotnet vstest .\Ocaramba.Tests.NUnit\bin\Release\net8.0\Ocaramba.Tests.NUnit.dll /TestCaseFilter:"(TestCategory=Grid)" /Parallel /Logger:"trx;LogFileName=Ocaramba.Tests.EdgeChrominum.xml"
- Home
- Getting started
- Ocaramba framework with Appium
- Parallel tests execution
- MsTest DataDriven tests from Xml and CSV files
- NUnit DataDriven tests from Xml, CSV and Excel files
- Comparing files by NUnit DataDriven tests
- Visual Testing
- Screen shots: full desktop, selenium. PageSource saving
- Verify-asserts without stop tests
- Downloading files
- Helpers
- Override browser profile preferences, install browser extensions, Headless mode
- Debugging Test.Automation framework
- Logging
- Performance measures
- Webdriver Extends
- More common locators
- Selenium-Grid-support
- Advanced Browser Capabilities and Options
- AngularJS synchronization
- Update App.config or appsettings.json
- Cross browser parallel test execution with testing-Cloud-Providers\SeleniumGrid
- Verifying Javascript Errors from browser
- Enabling Performance Log for Chrome
- Azure DevOps Support
- Edge browser Support
- Downloading and running Selenium Grid with Powershell
- Run Ocaramba tests with Docker container
- HTTP auth in Internet explorer
- ExtentReports Support