What behavior do you expect?
if you have this:
@Tag01
Scenario Outline: User Log In
... etc
Do you expect that to be BeforeScenario
called? Or only if you have both tags?
By the sounds of your question, you want it to be called if any of the tags exist, but only once.
, . - :
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;
}
}
}
, , , BeforeScenario:
[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");
}
}