New to Telerik Test Studio? Download free 30-day trial

Get Started with Data Driven Testing

This testing approach is useful for scenarios with certain actions and verifications, which need to be repeated multiple times.

What Test Scenario Can Be Data Driven?

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.

common-testing-approach

With data driven testing, the three steps related to the search action are reused and you save time and efforts.

How To Data Drive the Test?

Let's start by adding a new web test to your project.

Record the Steps to Data Drive

Open a browser and navigate to the Telerik page to start the recording session. Record the following actions:

  1. Click the Search icon in the top navigation bar.

  2. Enter 'Test Studio' in the Search field.

  3. Click the Search button.

record-search-actions

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.

Tip

For more details on wait steps, see here how to record one

For more details on steps using the text from an image, see here how to record such step.

Once all necessary steps are added to the test, close the browser to finish the recording session.

Prepare the Data Source

  1. Click the 'Local Data' tab located at the bottom of the test steps pane to switch to the built-in data table.

    switch-to-local-data

  2. 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.

    create-data-table

  3. Rename the column to correspond to the data that it contains - 'productName' for this scenario.

    rename-column

  4. Enter the names of the different products on each row.

    add-data

Tip

For more information, see how to modify the built-in data table.

Bind the Data to the Test Steps

Now that the data is in the built-in table, you can bind the values to the test steps:

  1. Switch back to the steps view by clicking the Test steps tab at the bottom of the test steps pane.

    switch-to-test-steps

  2. Click on the Enter text step (number 3. for the current scenario) and open the Step Properties pane.

  3. 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.

    enter-text-properties

    Note

    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.

  4. 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.

    select-column

  5. Click the Set button to confirm the selection and close the Properties pane.

    set-binding

    Tip

    See How to bind a step to a data source column for more information.

  6. 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.

    wait-step-binding

Execute the Data Driven Test and Review the Results

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.

execute-data-driven-test

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.

iterations-dropdown

Tip

For more information, see how to read the results of a data driven test.

Other data driven scenarios

In this article
Not finding the help you need? Improve this article