Here is a short summary of what we will cover in this post:
- Use Subject7 XPath/CSS Locator Explorer plugin to define locators
- Create a test hierarchy structure
- Generate the test steps that perform a login
- Use the data-driven functionality of Subject7 to run the same test with different data
- Group a set of test steps for reusability into functions
- Run the test locally on the tester’s machine
- Run the test on the cloud (AWS) on multiple browsers
- Browse recorded videos of the cloud run
For the purposes of this demo, we will be using the Yahoo login form as the example to cover the above points.
Locator Explorer Plugin
First, we will install Subject7’s Chrome plugin which helps us to quickly define the locators of the widgets we are interested in.
To define locators, navigate to the page where you want to record the web locators.
Next, enable the Subject7 Locator Explorer plugin by clicking on the Subject7 icon in the toolbar.
After you click on the widget which you want to define the locator for, you will see a visual indicator.
In the Yahoo login page, we are interested in the ‘Email address’ field and the ‘Next’ button.
When you click on the email field, a dialog pops up asking you to provide a hint for the element, in this case, we write email. This hint can be any visual cue for the widget on the screen (i.e. a button label, label before a text field, hint, etc.).
Using Locator Explorer, you do not need to inspect the element or look at the HTML/DOM at all.
Once you click ‘Generate’ button, a new dialog opens which lists the XPath and CSS selector for the HTML element we clicked on.
Once the XPath or CSS selector is identified by Locator Explorer, you can
click on ‘Test XPath’ button to make sure the correct widget is identified on
Once these are reviewed for accuracy, we then click on the button ‘Push to Server’ which stores the locator on the Subject7’s object repository.
We repeat the above steps for the ‘Next’ button.
Creating Test Folder Structure and Test Steps
- To create a folder structure, we first go to Library and select Tests
- Once we are in that screen, click on New Folder
- When the New Folder dialog opens, type in a name and click Save. This will create a new folder with the name you provided
- Next, click on the folder name you just created to go inside the folder
- Next, click the New Test Suite and then provide a name for the test suite and click Save
- Select the test suite you just created and click on New Test Case where you can choose whether to create a manual test case or an automated test case
- In this tutorial, we cover the automated test case creation, so select automated and provide the name for the test
Add the test steps
The first thing we want to do is to navigate to the login page. We do this by clicking the wizard icon, which opens a new tab where we can choose a command from a drop-down menu.
Select GO_TO command from the drop down and then provide the URL.
Next, we want to fill in the email address in the login form. To add another step, click the down arrow, which adds another row after the first test step.
Select FILL from the commands drop-down menu and then select the email locator which we recorded previously using the Locator Explorer plugin. As we are filling an input box, we also need to provide the text to enter in the input box. We do this by filling in the value text field.
Finally, after we fill in the email address, we want to click on the ‘Next’ button.
Once again, we click on the down arrow but this time we select CLICK option from the commands drop-down menu and we also select the locator for the ‘Next’ button.
Once all the test steps have been constructed, we click on the save icon to save the steps.
Subject7 caters for data-driven testing. For example, if we wanted to test our Yahoo login form with multiple users, we can create a test data template where we can add our test data. Once this is done, we can then instruct our test steps to use the template.
Create New Data Template
From the top menu, click Artifacts and then select Data Templates.
Create a new template by clicking on ‘New’ and then providing a name for the template.
At the bottom of the New Data Template screen, we can add the new data template fields. For this example, we are going to add a template that has username and password fields.
Once we have defined our data template, we can then provide different values to the template.
On the Data Sets template, we should see our Data Template we just created. All we need to do now is to provide the actual data we want to use in our login test.
For the purposes of this demo, we will only create two rows of data. Alternatively, you can use the upload button to load multiple data sets from a CSV file.
Injecting Test Data
Now that we have defined our template and provided the data, we can inject them in our login test case.
To do this, find the test step which fills in the email address and click the wizard icon to edit the step. Once the wizard opens, delete the value which was provided earlier and click the inject template link.
From the Template Injector pop-up menu, select the template and the field, which in this case will be the username.
Once, this is done, you will notice that the command for that step is much longer and contains the details of the template name and the specific field. Username is no longer hard-coded in our test case.
Test Steps Grouping
Another useful feature of Subject7 is the ability to group test steps for reusability. For example, if we wanted to reuse the same login steps in multiple test suites, we can group the login steps into a function.
This is easily achieved by selecting relevant test steps under G column (for
Grouping) and clicking on the gear icon (i.e. 4th icon to the right of
Status). Once the ‘New Function’ dialog opens, provide a name for the function and click Group.
The grouped test steps will now appear under one step which starts with a ‘CALL’ command and a ‘+’ icon.
You can also find the newly created functions under Library from the top menu and then Functions submenu.
Local Test Run
To execute the automated test with Subject7, click on the play icon which starts executing the tests on the local machine. You can use the local run to author, debug, and troubleshoot the flow that you are trying to automate.
Executing tests on the cloud
To execute the tests on the cloud (AWS), we first have to create an execution set.
From Library, select Execution Sets
Click on the New Execution Set to set up a cloud run
On the Execution Set screen, enter a name for the cloud run and select the default pool.
You can also configure which browsers you want the tests to run on by selecting the browsers from the Browser Type drop down.
Next, click on ‘Test Case and Data Set Selection’ tab to select the test cases and the data set.
Because we have parameterized our test, we can now run the same test with multiple data sets and of course multiple browsers.
Once you have selected the test case and the data sets, click on Save button.
When the execution set is created, you can then select it and click on cloud run which would start to execute the tests on the cloud platform with the chosen browsers and data sets.
You can see the progress of the execution by clicking on the execution set you created, which will list the live progress of the run. As each run completes, a Green check mark is inserted against the test.
You can also see the recording of the run by clicking on the camcorder icon against each test run once each test is completed on the cloud.