Skip to content

Instantly share code, notes, and snippets.

@ultimate-qa2
Created February 14, 2021 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ultimate-qa2/a4b3faac469150930e07db818988d225 to your computer and use it in GitHub Desktop.
Save ultimate-qa2/a4b3faac469150930e07db818988d225 to your computer and use it in GitHub Desktop.
Hooks class for SpecFlow parallelization
[Binding]
public class Hooks
{
public IWebDriver Driver { get; }
private readonly ScenarioContext _scenarioContext;
public Hooks(IWebDriver driver, ScenarioContext scenarioContext)
{
Driver = driver;
_scenarioContext = scenarioContext;
}
[AfterScenario]
public void Teardown()
{
if (Driver == null){ return; }
var passed = _scenarioContext.ScenarioExecutionStatus == ScenarioExecutionStatus.OK;
((IJavaScriptExecutor)Driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed"));
Driver.Quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment