Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Skip screenshot for screenshot exceptions (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Sep 21, 2016
1 parent 19aaa0d commit 36e8335
Showing 1 changed file with 10 additions and 2 deletions.
Expand Up @@ -49,6 +49,7 @@ public class TestEventForScreenshotListener extends AbstractWebDriverEventListen

private final WebDriver driver;
private String testId = "";
private boolean handlingException;

/**
* A registered TestEventListener will perform actions on navigate,
Expand Down Expand Up @@ -160,6 +161,11 @@ public void afterClickOn(WebElement element, WebDriver driver) {

@Override
public void onException(Throwable throwable, WebDriver driver) {
if (handlingException) {
log.error("skipping screenshot for exception in exception handler", throwable);
return;
}
handlingException = true;
try {
createScreenshot("_exc");
// try to let the browser recover for the next test
Expand All @@ -168,8 +174,10 @@ public void onException(Throwable throwable, WebDriver driver) {
log.error("dismissing unexpected alert with text: ", alert.get().getText());
alert.get().dismiss();
}
} catch (Throwable all) {
log.error("error creating screenshot on exception", all);
} catch (Throwable screenshotThrowable) {
log.error("unable to create exception screenshot", screenshotThrowable);
} finally {
handlingException = false;
}
}

Expand Down

0 comments on commit 36e8335

Please sign in to comment.