Specflow scenario with two tags opens two windows Specflow scenario with two tags opens two windows selenium selenium

Specflow scenario with two tags opens two windows


What behaviour do you expect?

if you have this:

@Tag01Scenario Outline: User Log In... etc

do you expect the BeforeScenario to be invoked? Or only if you have both tags?

By the sounds of your question you want it invoked if either of the tags exist, but only once.

I think you'll have to handle this yourself. Something like this should do it:

public class Hooks{    private bool BeforeScenarioDoneAlready{get;set;}    [BeforeScenario("Tag01", "Tag02")]    public void BeforeScenario()    {        if (!DoneBeforeScenarioAlready)        {             StepBase.CreateBrowser(ConfigurationManager.AppSettings["BrowserType"]);             Console.WriteLine("selenium open Called");             BeforeScenarioDoneAlready=true;        }    }}

if you want it to only be done if both tags exist then you can check this in your BeforeScenario method:

[BeforeScenario()]public void BeforeScenario(){    if(ScenarioContext.Current.ScenarioInfo.Tags.Contains("Tag01")      && ScenarioContext.Current.ScenarioInfo.Tags.Contains("Tag02"))    {         StepBase.CreateBrowser(ConfigurationManager.AppSettings["BrowserType"]);         Console.WriteLine("selenium open Called");    }}