Test Studio allows you to use external data files for data driven testing. This is a suitable option when the data required for the test is more complex and is maintained easier in external type of file or is exported from a different tool.
Let's start by adding a new test in the project and recording the steps to data drive. We can use the same test sample, described for the data driven test with built-in data.
Open a browser and navigate to the Telerik page to start the recording session. Record the following actions:
Click on the Search icon in the top navigation bar.
Enter 'Test Studio' in the Search field.
Click on the Search button.
To ensure that the search was performed correctly, add a step that waits until the first item of the results list contains the searched product name.
Once you add all necessary steps to the test, close the browser to finish the recording session.
To demonstrate the usage of external data source, let's prepare a sample Excel file. The data we need for this test is listed in a single row and contains different Telerik product names to search in the site.
The first row will be used to refer the column when binding it to the test steps. This is 'productName' in the described scenario.
To use the external file in a Test Studio project, you need to add a reference to this file in the project. Select the
Project tab in the Test Studio window and hit the
Add button from the
Data Source section in the ribbon.
For more information, see How to add supported data files in the project.
Now that you have added a data source definition to your test project, you are ready to bind your test to that data source.
Choose a test from the
Project Explorer and click the
Bind Test button from the
Data Source section in the
When the external data source is configured as desired, click the
OK button to bind it to the selected test. Now the external file is associated with the test, and you can access the data values in the file and bind them to the steps.
For more information, see How to bind a test to the external data file.
Once the test has a reference to the data source, you can bind the values to the test steps:
Select the Enter text step (number 8. for the current scenario) and expand it with double-click.
Data Bindbutton to open the
Data bindingdialog. It lists all step's fields which you can use for binding.
The Enter text step allows only its
Textfield to be data driven so this is the only one listed in the
Binding dialog. Click on the drop-down next to the
Textfield and expand the data source columns list. In this scenario the data consists of a single column - the
productName, so select this one.
See How to bind a step to a data source column for more details.
Confirm the binding with the
The step gets updated and hints that is bound to some data.
Repeat the same sequence of actions for the Wait step. This step verifies that the search action is completed successfully. The field to bind in the Wait step properties is
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.
- 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