Skip to content

Commit

Permalink
Take UnsupportedCommandException into account for element screenshots (
Browse files Browse the repository at this point in the history
…#848)

* Take UnsupportedCommandException into account for element screenshots
  • Loading branch information
Artur- authored and alvarezguille committed Dec 2, 2016
1 parent b8c3bb2 commit 83063b5
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ private static BufferedImage getScreenshot(TakesScreenshot driver,
byte[] screenshotBytes = screenshotContext
.getScreenshotAs(OutputType.BYTES);
supportsElementScreenshots = true;
System.out
.println(driver + " supports element screenshots");
return ImageIO
.read(new ByteArrayInputStream(screenshotBytes));
} catch (UnsupportedCommandException e) {
supportsElementScreenshots = false;
} catch (WebDriverException e) {
if (e.getCause() instanceof UnsupportedCommandException) {
System.out.println(driver
+ " DOES NOT support element screenshots");
supportsElementScreenshots = false;
} else {
throw e;
Expand All @@ -95,9 +93,7 @@ private static BufferedImage getScreenshot(TakesScreenshot driver,
}
}

if (elementScreenshot && !supportsElementScreenshots)

{
if (elementScreenshot && !supportsElementScreenshots) {
// Driver does not support element screenshots, get whole screen
// and crop
BufferedImage image = ImageIO.read(new ByteArrayInputStream(
Expand Down

0 comments on commit 83063b5

Please sign in to comment.