Last updated on : 21 Jan 2025
Appium Step View
Overview
Appium Step View displays detailed step-level execution data for your automation sessions. To enable this feature, step reporting must be added in the test script using driver.executeScript("mobile:report:step", params);. If step logging is not done, no steps will appear in the session report.
Step View Enablement Guide
Step View will only display data if step-level data is added in your automation script. If step logging is not done, the session will show 'No steps available'.
Required Parameters for Step Reporting
- stepName – Unique name of the step
- startTime – Step start time 3. endTime – Step end time
- stepStatus – PASS or FAIL
- reason – Failure reason (if any)
- stackTrace – Error stack trace (if failed)
Example Step Logging Structure
Json
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");
String startTime = LocalDateTime.now().format(formatter);
**boolean** isStepFailed = **false**;
try {
driver.findElement(By.xpath("your_locator")).sendKeys("demo");
String endTime = LocalDateTime.now().format(formatter);
Map<String, Object> params = new HashMap<>();
params.put("stepName", "emailIdEntered");
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("stepStatus", "PASS");
params.put("reason", "");
params.put("stackTrace", "");
driver.executeScript("mobile:report:step", params);
System.out.println("===== Step Params (PASS) =====");
for (Map.Entry<String, Object> entry : params.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
} catch (Exception e) {
String endTime = LocalDateTime.now().format(formatter);
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String stackTraceStr = sw.toString();
Map<String, Object> params = new HashMap<>();
params.put("stepName", "emailIdEntered");
params.put("startTime", startTime);
params.put("endTime", endTime);
params.put("stepStatus", "FAIL");
params.put("reason", e.getMessage() != **null** ? e.getMessage() : e.toString());
params.put("stackTrace", stackTraceStr);
System.out.println("===== Step Params (PASS) =====");
for (Map.Entry<String, Object> entry : params.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
driver.executeScript("mobile:report:step", params);
//throw e;
isStepFailed = **true**;
}
Important Notes
- Step reporting must be added for every test step you want to track.
- If driver.executeScript('mobile:report:step', params) is not used, the step will not appear.
- Ensure each step has a unique stepName.
- Always handle both PASS and FAIL scenarios.
After updating the script, re-run the session
Did this page help you?