I have at least 3 .feature files in my C# Specflow tests project in which I have the step, for instance:
Given I am at the Home Page
When I first wrote the step in the file Feateure1.feature
and created the step method, I placed it in a step file, let's say, Steps1.cs
, which inherits from a base class that initializes a FirefoxDriver
. All my StepsXXXX.cs
classes inherit from this base class.
Then, I wrote Feature2.feature
, which also has a step Given I am at the Home Page
. And the step was automaticaly bound to the one in Steps1.cs
'Till now, no problem. That's pretty much what I wanted - to have reusable steps throughout the test project. But the problem is, whenever I'm running a scenario that has steps in diferent StepsXXXX
files, I get various browser instances running.
======
I'm pretty sure this is due to the fact that My StepsXXXX
(binding classes) all inherit from this base class that has a IWebDriver of its own, and when the step is called, everything else (including the before/after scenario methods) is called. But I can't figure out how to work around this.
I still want reusable steps. I tried to put these steps in the base class, but it did not work. I thought of changing the bindings too, but specflow uses meaningfull strings to do so, and I don't want to change them to misleading strings.
Has anyone stumbled across this? Any help is really appreciated.