Created
September 23, 2021 10:01
-
-
Save mattonem/45192370afbd8720deb8dc0efe952065 to your computer and use it in GitHub Desktop.
testNG update browserstack session status accordingly to test result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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