Screenshots on failure for browser tests using Selenium WebDriver

tonytony Posts: 11

As of SOAtest 9.10.2 you can automatically take screenshots when browser tests running with Selenium WebDriver fail. This lets you see what happened in the browser even if you weren't able to watch it happen during the test run. SOAtest can save your screenshots to a folder or embed them directly into HTML reports.

For now you set a Java system property to turn this feature on and tell SOAtest how to save screenshots. In the future we might move this setting to a preference and remove the system property. Set the property "com.parasoft.tool.screenshot.Location" to either a directory path or to "". Using a directory path like "C:/nightly/screenshots/" tells SOAtest to save screenshots to the directory. Using "" tells SOAtest to embed screenshots directly in the HTML report.

There are a lot of ways to set Java system properties depending on how you're using SOAtest. You could define the property when launching SOAtest by adding -J-Dcom.parasoft.tool.screenshot.Location="" to the command used to start SOAtest. Or you could run an Extension Tool that sets the property. Here's an example in Groovy:

def setScreenshots() {
    System.setProperty("com.parasoft.tool.screenshot.Location", "C:\\nightly\screenshots");
}

Once you set the property, SOAtest will take a screenshot every time a browser test running with Selenium WebDriver fails. If you want your screenshots saved to a directory but also want them to appear in your reports, make sure you generate your report in the same directory where SOAtest saved your screenshots.

Comments

  • tonytony Posts: 11

    A couple of corrections for the post above:

    • The special value for embedded screenshots is <embed> so in the examples above it should say:

      • Set the property "com.parasoft.tool.screenshot.Location" to either a directory path or to "<embed>"
      • You could define the property when launching SOAtest by adding -J-Dcom.parasoft.tool.screenshot.Location="<embed>" to the command used to start SOAtest.
    • The Extension Tool example is missing a \ after "nightly", so it should be:

    def setScreenshots() {
        System.setProperty("com.parasoft.tool.screenshot.Location", "C:\\nightly\\screenshots");
    }
    
  • VinayVinay Posts: 8

    In addition, after enabling above setting if you decide to disable this setting on fly for some reason (Usecase: I know why certain tests are failing and don't want the screenshot for all those to reduce my report size) you can set the same property with an empty string ("").
    Something like this:
    System.setProperty("com.parasoft.tool.screenshot.Location", "");

Sign In or Register to comment.