Skip to content

Instantly share code, notes, and snippets.

@melagiri
Created April 6, 2018 08:49
Show Gist options
  • Select an option

  • Save melagiri/32bed04b91cf656a3b2016f757a1b7c7 to your computer and use it in GitHub Desktop.

Select an option

Save melagiri/32bed04b91cf656a3b2016f757a1b7c7 to your computer and use it in GitHub Desktop.
public class TestStepListener extends BasePortalTest implements StepLifecycleListener
{
public void beforeStepStop(final StepResult result)
{
System.out.println("Step: " + result.getName() + ": " + result.getStatus());
try
{
// Get Test Instance
WebDriver driver = ((BasePortalTest) this).browser;
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtil.moveFile(screenshot, new File(testLogFolder.getPath() + "\\" + result.getName() + ".png"));
}
catch (Exception e)
{
System.out.println("Failed Exception");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment