This testing approach is useful for scenarios with certain actions and verifications, which need to be repeated multiple times.
The easiest answer is that each scenario can be data driven. Test Studio allows you to use data source values for both input fields and verifications. For example, if you need to perform the same actions against an application, but by using multiple different users, you can data drive the login input information.
To demonstrate the capabilities of data driven testing, we will use a test scenario, which navigates to the Telerik page, enters different product names in the Search field, and checks the outcome of the results. If you use the common, non data driven testing approach, you will end up with a test that needs three test steps for each individual product that you enter in the search field.
With data driven testing, the three steps related to the search action are reused and you save time and efforts.
Let's start by adding a new web test to your project.
Open a browser and navigate to the Telerik page to start the recording session. Record the following actions:
Click the Search icon in the top navigation bar.
Enter 'Test Studio' in the Search field.
Click the Search button.
To ensure that the search is performed correctly, we recommend to add a step that waits until the first item in the results list contains the searched product name.
Once all necessary steps are added to the test, close the browser to finish the recording session.
Click the 'Local Data' tab located at the bottom of the test steps pane to switch to the built-in data table.
In the local data tab, specify the number of columns and rows and create a table. For the current scenario we need a single column and three rows.
Rename the column to correspond to the data that it contains - 'productName' for this scenario.
Enter the names of the different products on each row.
For more information, see how to modify the built-in data table.
Now that the data is in the built-in table, you can bind the values to the test steps:
Switch back to the steps view by clicking the Test steps tab at the bottom of the test steps pane.
Click on the Enter text step (number 3. for the current scenario) and open the Step Properties pane.
The Bindings property is the first in the list. Click the three dots button on the right to open the step fields that you can bind to data.
Depending on the project layout you are using, the Properties pane can have a different location within your project.
The Enter text step allows only its Text field to be data driven and, thus, it is the only one listed.
Click on the drop-down next to the Text field to expand the data source columns list. In this scenario, there is a single column in the list - the productName, so select this one.
Click the Set button to confirm the selection and close the Properties pane.
See How to bind a step to a data source column for more information.
Apply the same sequence of steps for the wait step. We add a wait step to verify that the search action is completed successfully. Note that the field that you need to bind in the wait step properties is TextToMatch.
Now that the test is set up to take data from the built-in data table, you can see the two data-bound steps and the column they are connected to. To run the test, hit the Execute button and choose a browser for the execution.
Observing the test run, you will see that the 5 steps recorded in the test will be executed three times in a row. The difference in each of these iterations will be the product name entered in the Search field. This name corresponds to the products listed in the data table.
Once the test run finishes, you will see the quick execution results populated in the Test Pane. The results for each iteration are listed separately, and you can switch between them from the Iterations drop-down.
For more information, see how to read the results of a data driven test.
- Data drive a test using external data source
- Test as steps used with data driven testing
- Data drive the find expression of an element in Test Studio
- Use data source columns in coded steps