Grouping - Automation Commands
Description
The grouping functions allow you to group steps together, making the generated test reports easier to read and manage. This helps reduce the overall number of steps displayed, improving performance when viewing reports with many steps.
The grouping functions include:
startStepsGroup
- Starts a group of stepssetGroupStatus
- Sets the status of the group to either Passed or FailedstopStepsGroup
- Ends the grouping of steps
Parameters
startStepsGroup
Parameter Name | Value | Description |
---|---|---|
groupName | String | Specifies the name for the group that will appear visually in the generated report, helping to identify and categorize the grouped steps |
setGroupStatus
Parameter Name | Value | Description |
---|---|---|
status | String | A status for the group. Accepted values are Passed or Failed |
stopStepsGroup
No parameters required. Ends the grouping that was started with StartStepsGroup
.
Code Example
The grouping
commands can be executed using the executeScript function:
Java-
- driver.executeScript("seetest:client.startStepsGroup", groupName);
- driver.executeScript("seetest:client.setGroupStatus", status);
- driver.executeScript("seetest:client.stopStepsGroup");
Python-
- driver.execute_script("seetest:client.startStepsGroup", group_name)
- driver.execute_script("seetest:client.setGroupStatus", status)
- driver.execute_script("seetest:client.stopStepsGroup")
C#-
- driver.ExecuteScript("seetest:client.startStepsGroup", groupName);
- driver.ExecuteScript("seetest:client.setGroupStatus", status);
- driver.ExecuteScript("seetest:client.stopStepsGroup");
JavaScript-
- driver.executeScript("seetest:client.startStepsGroup", groupName);
- driver.executeScript("seetest:client.setGroupStatus", status);
- driver.executeScript("seetest:client.stopStepsGroup");
Ruby-
- driver.execute_script("seetest:client.startStepsGroup", group_name)
- driver.execute_script("seetest:client.setGroupStatus", status)
- driver.execute_script("seetest:client.stopStepsGroup")
Practical Example
Imagine running an automated test with several steps validating various aspects of the application. If there are steps related to specific areas of the application, grouping those steps can improve report clarity.
For instance, in a banking application, the login process might involve several steps before proceeding to the payment process. By grouping the login steps, you can easily identify the success or failure of the login process based on the group status.
Without grouping, a login scenario might look like this in your script:
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(LOGIN_LOGO)));
driver.findElement(By.xpath(USERNAME_TEXTFIELD)).sendKeys(username);
driver.findElement(By.xpath(PASSWORD_TEXTFIELD)).sendKeys(password);
driver.findElement(By.xpath(LOGIN_BUTTON)).click();
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(BALANCE_AMOUNT)));
With grouping functions, the scenario would be written as follows:
driver.executeScript("seetest:client.startStepsGroup", "Login_Steps");
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(LOGIN_LOGO)));
driver.findElement(By.xpath(USERNAME_TEXTFIELD)).sendKeys(username);
driver.findElement(By.xpath(PASSWORD_TEXTFIELD)).sendKeys(password);
driver.findElement(By.xpath(LOGIN_BUTTON)).click();
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(BALANCE_AMOUNT)));
driver.executeScript("seetest:client.setGroupStatus", "Passed");
driver.executeScript("seetest:client.stopStepsGroup");
Once the grouping functions are used, the test reports will display the groups as collapsible sections, making it easier to identify which group Passed or Failed.
You can create as many groups as needed in your test. However, each group requires a start and stop function before a new group can begin. Groups cannot be nested within each other.