How to take a screenshot at a specific Event in QAS from the code level

QAS supports capturing screenshots automatically for Failure and Success checkpoints when the Test cases are executed via the command line terminal. However, sometimes users want to generate a screenshot for events. In such cases users can follow the below steps to capture the screenshot from the code level:

  1. Create Method in stepsLibrary.java ('src\test\java\steps\common')

  2. Import statement to import class:

  3. import com.qmetry.qaf.automation.util.Reporter;
  4. Create a method for screenshot capture() and use any of the checkpoints mentioned below based on your requirement:

  5. @QAFTestStep(description = "capturescreenshot") public static void capturescreenshot() {​​ //Checkpoint with message Reporter.log("you message"); OR //Checkpoint with message and screenshot Reporter.logWithScreenShot("you message"); OR //Checkpoint with message types Reporter.logWithScreenShot("you message", MessageTypes.Info) }​​
  6. Now in BDD, the user can access the method 'capturescreenshot' required events and capture the screenshots:

  7. And capturescreenshot

8. The users can also set Properties with the below values to enable/disable capturing of the screenshots at success and failure checkpoints in the application.properties file:

a. Open resources > application.properties file

b. Set Properties with the default values:

Parameter Key

Default Value

Description

Parameter Key

Default Value

Description

selenium.success.screenshots

1 - Enable

Specify whether to capture screenshot or not on checkpoint success. Possible values 0 or 1, true or false.

selenium.failure.screenshots

1 - Enable

Specify whether to capture screenshot or not on checkpoint failure. Possible values 0 or 1, true or false.