Screenshot Extension >

Screenshot Listener

The Screenshot extension can act as a listener to Concordion commands. It invokes a ScreenshotTaker to save the image to file, then decorates the HTML element containing the command with attributes to show the image. The attributes display the image when it is hovered over, and open it up in a browser when clicked.

By default, it captures a screenshot whenever an assertion fails, or an uncaught Throwable occurs.

Example - Failure

<p concordion:assertEquals="acronym">ABC</p>

When run with a fixture that returns an acroynm value of XYZ, it becomes:

<p concordion:assertEquals="acronym" class="failure" _
 onMouseOver="if (showScreenshotOn(event)) {show('ScreenshotListener_img1.jpg');this.style.cursor='pointer'}" _
 onMouseOut="hide('ScreenshotListener_img1.jpg');this.style.cursor='default'" _
 onClick="if (showScreenshotOn(event)) {hide('ScreenshotListener_img1.jpg');window.location.href='ScreenshotListener_img1.jpg'}"> _
<del class="expected">ABC</del> 
<ins class="actual">XYZ</ins> _
<a href="ScreenshotListener_img1.jpg"><img id="ScreenshotListener_img1.jpg" src="ScreenshotListener_img1.jpg" width="600" class="screenshot" /> _
</a> _
</p>

Example - Exception

<p concordion:assertEquals="divide(1, 0)">infinity</p>

When an exception occurs in the divideByZero() fixture method, the HTML output with the stack traces removed is:

<p concordion:assertEquals="divide(1, 0)" _
 onMouseOver="if (showScreenshotOn(event)) {show('ScreenshotListener_img1.jpg');this.style.cursor='pointer'}" _
 onMouseOut="hide('ScreenshotListener_img1.jpg');this.style.cursor='default'" _
 onClick="if (showScreenshotOn(event)) {hide('ScreenshotListener_img1.jpg');window.location.href='ScreenshotListener_img1.jpg'}"> _
<span class="failure"><del class="expected">infinity</del></span> _
<span class="exceptionMessage">Invalid expression [divide(1, 0)]</span> _
<input class="stackTraceButton" id="stackTraceButton1" type="button" onclick="javascript:toggleStackTrace('1')" value="View Stack" /> _
<div class="stackTrace" id="stackTrace1"><p>While evaluating expression: <code>divide(1, 0)</code></p> _
<div class="stackTraceExceptionMessage">java.lang.RuntimeException: Invalid expression [divide(1, 0)]</div>
...
/div></div><a href="ScreenshotListener_img1.jpg"><img id="ScreenshotListener_img1.jpg" src="ScreenshotListener_img1.jpg" width="600" class="screenshot" /></a></p>

Further Details