Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just found an article that explains a much better way to do it: <a href="http://darrellgrainger.blogspot.com/2011/02/generating-screen-capture-on-exception.html" rel="nofollow">http://darrellgrainger.blogspot.com/2011/02/generating-screen-capture-on-exception.html</a></p> <p>How does it work?<br> Effectively, you pass in a custom WebDriverEventListener, which has functions that will be called on certain events. One of those events is onException(). So every time an exception is thrown by WebDriver, you can write the code to take a screenshot.</p> <p><s>I have seen three different ways to do this:</p> <ol> <li><p>If you have a static driver, the easiest way is to set up a listener in TestNG (Overridding <a href="http://testng.org/javadoc/org/testng/TestListenerAdapter.html" rel="nofollow">TestListenerAdapter</a>), and then to take a screenshot in the onTestFailure() method.</p></li> <li><p>My personal method is to use the Selenium Page Object pattern, but modified a bit. I have created an EnhancedWebElement object that wraps and extends a normal WebElement, and has a reference to the driver. Then in each of the methods that WebElement has, I perform the call in a try/catch and in the catch, I then take a screenshot. I'm open to sharing the code, but I'd have to trim away quite a bit to post here, so please tell me if you want to see it.</p></li> <li><p>Alternatively, you can set up a proxy around the WebElement or the Driver itself and have it catch everything. I haven't done this, but I've seen it work on other projects. </s></p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload