Report - Automation Command
Description
The report command allows you to add custom steps in your test reports, marking them as either Passed or Failed. This command is particularly useful for providing detailed feedback in reports and simplifying post-test analysis.
Parameters
| Parameter Name | Value | Description |
|---|---|---|
message | String | A custom message to display in the report |
status | Boolean | True marks the step as passed, False marks it as failed |
Code Example
The report command can be executed using the executeScript function:
- Java
- Python
- C#
- JavaScript
- Ruby
driver.executeScript("seetest:client.report", message, status);
self.driver.execute_script("seetest:client.report", message, status);
driver.ExecuteScript("seetest:client.report", message, status);
driver.executeScript("seetest:client.report", message, status);
driver.executeScript("seetest:client.report", message, status);
Practical Example
Imagine you're testing a banking application, and you need to verify that a payment has been successfully processed. You might assert that the balance before and after the payment is different. Without the report command, it may look something like this:
String balanceBeforePayment = "$500";
String balanceAfterPayment = "$450";
String outputIfAssertionFailure = "Amount has not been deducted.";
assertNotEquals(balanceBeforePayment, balanceAfterPayment, outputIfAssertionFailure);
In an enhanced version where you are using the report command to log the result, it may look something like this:
try {
assertNotEquals(balanceBeforePayment, balanceAfterPayment, outputIfAssertionFailure);
driver.executeScript("seetest:client.report", "Amount has been deducted", "true");
driver.executeScript("seetest:client.report", "Previous Balance: " + balanceBeforePayment + ", Current Balance: " + balanceAfterPayment, "true");
} catch (AssertionError e) {
driver.executeScript("seetest:client.report", e.getStackTrace(), "false");
driver.executeScript("seetest:client.report", "Amount has NOT been deducted", "false");
driver.executeScript("seetest:client.report", "Previous Balance: " + balanceBeforePayment + ", Current Balance: " + balanceAfterPayment, "false");
throw e;
}
In case of failure, this is what the above code would display in the report generated:

Be cautious when marking a step as "failed" using the report command. A failed step will mark the entire test as failed, unless overridden by the setReportStatus command.