Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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