Skip to content

Instantly share code, notes, and snippets.

@mattonem
Created September 23, 2021 10:01
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 mattonem/45192370afbd8720deb8dc0efe952065 to your computer and use it in GitHub Desktop.
Save mattonem/45192370afbd8720deb8dc0efe952065 to your computer and use it in GitHub Desktop.
testNG update browserstack session status accordingly to test result
@AfterMethod
public void afterMethod(ITestResult result) {
if(result.getStatus() == SUCCESS)
{
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor: {
\"action\": \"setSessionStatus\",
\"arguments\": {\"status\": \"passed\", \"reason\": \""+restult.getName()+" succeeded\"}}");
}
else
{
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("browserstack_executor: {
\"action\": \"setSessionStatus\",
\"arguments\": {\"status\": \"failed\", \"reason\": \""+restult.getName()+" failed\"}}");
}
driver.quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment