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/SpecflowSeleniumParallelHere are the complete videos of the above discussion
Video 1