public byte [ ] findScreenshot ( Throwable t ) { byte [ ] result = null ; if ( t != null ) { if ( t instanceof ScreenshotException ) { String encodedScreenshot = ( ( ScreenshotException ) t ) . getBase64EncodedScreenshot ( ) ; result = Base64 . getDecoder ( ) . decode ( encodedScreenshot ) ; } else { result = findScreenshot ( t . getCause ( ) ) ; } } return result ; }
Finds screenshot embedded in throwable if any .