6.1 C
New York
Friday, November 29, 2024

automated testing – Strategies to setup parallel check execution in NUnit with Selenium WebDriver C#


I’ve encountered this actual difficulty that you’re dealing with and from my observations I can recommend 3 potential options:

1. ThreadStatic driver – it is the only strategy to have a novel driver occasion per TestMethod. The precise worth of the driving force is linked to the thread your check is working on. Simply bear in mind to make use of [TearDown] to shut the driving force occasion after the check is completed.

NOTE: Every [TestMethod] within a [TestFixture] has its personal TestContext and runs on it is personal thread when utilizing parallelization. This context is created in the course of the [SetUp] technique and persists till [TearDown].

2. A number of courses in the identical file – you may place a number of courses marked as [TestFixture] in the identical file and below the identical Namespace. They will lengthen a base check class and have their very own distinctive driver. The disadvantage is that you’ll have to handle every courses’ driver individually.

3. Instantiate your driver within your Web page Objects – this answer includes having one PageObject class (in case you are conversant in the Web page-Object sample) which initializes your driver after which injects it into different PageObject courses.

For instance: say you might have a HomePage class. This class has a Driver property and if you invoke one thing like HomePage.GoTo() or .OpenBrowser() this Driver property will get a price assigned, relying in your configurations or any parameters chances are you’ll need to give the strategy. Then if you navigate out of your HomePage to a different web page, say “SettingsPage” you may have a technique referred to as HomePage.GoToSettingsPage() which returns a new SettingsPage(myDriver) and passes it your driver via the constructor. In fact, this may restrict your potential to create new PageObjects at any level in your check apart from the primary one. Each time you navigate from one PageObject to a different you’ll need to cross the driving force.
The primary concept is to uncouple your driver occasion from the check class.

There is likely to be different methods, however I hope my ideas helped.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles