Site Loader
Auckland, New Zealand
In the last post we discussed how to work with Specflow 2.0 parallel execution, in this post we will discuss how to run Multiple tests in parallel in multiple browser same time using Specflow + NUnit + Selenium.

Problem with Selenium WebDriver object while running Specflow test in Parallel

Since we will be using selenium webdriver object in many Specflow step definitions and while running tests in parallel, we will encounter NullReferenceException , in order to resolve the problem, we need to use two important techniques
  • Context injection (dependency injection)
  • IOC Container

IOC Container

  • In software engineering, inversion of control (IoC) is a design principle in which custom-written portions of a computer program receive the flow of control from a generic framework.
  • A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the framework that calls into the custom, or task-specific, code.

-Source : Wikipedia

So how code looks like for IOC Container?

https://gist.github.com/executeautomation/23512f1f8f392832ab31b690484d1375 Here is the complete source code in GitHub https://github.com/executeautomation/SpecflowSeleniumParallel

Here are the complete videos of the above discussion

Video 1

Video 2 Thanks for reading the post and watching the video!!! Please leave your comments and let me know if there is anything I should update in this post. Thanks, Karthik KK

Post Author: Karthik kk

4 Replies to “Parallel execution with Specflow 2.0 + NUnit + Selenium”

  1. Hi Karthik,
    This is nice and very useful. However, I feel it’s not complete. You didn’t demo how we can do parrallel testing with multiple browsers with IObjectContainer. Unlike the Hooks.cs file in the non specflow tests, which showed how you can use multiple browsers in the tests, this is not covered in the Specflow version.

  2. Hai,

    Im executing the 60 test cases through command line, here thing all 60 browsers are lunching at a time ,but I need to control the browsers lunching through command line

  3. It’s possilbe to implement by features?. Because if I have 20 scenarios, This code will open 20 browsers no?

Leave a Reply to Karthik kk Cancel reply

Your email address will not be published. Required fields are marked *