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

## <strong>What Test Scenario Can Be Data Driven?</strong>

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](https://www.telerik.com/teststudio/documentation/assets/d4d1236d7c955410a351e03665ebf3a3/common-testing-approach.png)

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

## <strong>How To Data Drive the Test?</strong>

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](https://www.telerik.com/teststudio/documentation/assets/55b8d0de77268f4bdc84fa1cb05c189e/record-search-actions.png)

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**
> <br>
> <br>
> For more details on **wait steps**, see <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/wait" target="_blank">here how to record one</a>
> <br>
> <br>
> For more details on steps using the **text from an image**, see <a href="/features/recorder/advanced-recording-tools/element-steps/verifications/text-from-image" target="_blank">here how to record such step</a>.

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 pane to switch to the built-in data table.

   ![switch-to-local-data](https://www.telerik.com/teststudio/documentation/assets/57d36ba055c99cb672049a7a9bd39053/switch-to-local-data.png)

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](https://www.telerik.com/teststudio/documentation/assets/344d32db6eaef59c383b684909c2b8ee/create-data-table.png)

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

   ![rename-column](https://www.telerik.com/teststudio/documentation/assets/cd1a587a5e8b676d72a2099d891ece9c/rename-column.png)

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

   ![add-data](https://www.telerik.com/teststudio/documentation/assets/bf197320a28b8a565bb5394c788fd64f/add-data.png)

> **Tip**
> <br>
> <br>
> For more information, see <a href="/features/data-driven-testing/manage-local-data" target="_blank">how to modify the built-in data table</a>.

## 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 pane.

   ![switch-to-test-steps](https://www.telerik.com/teststudio/documentation/assets/bb79f601cab3fa9ebd995886b202d494/switch-to-test-steps.png)

2. Select the **Enter text** step (number 8. for the current scenario) and expand it with double-click.

   ![expand-step](https://www.telerik.com/teststudio/documentation/assets/759ac19df73442508065dd41e4d0b7df/expand-step.png)

3. Use the `Data Bind` button to open the `Data binding` dialog. It lists all step's fields which you can use for binding.

   ![data-bind-dialog](https://www.telerik.com/teststudio/documentation/assets/0f282d9ccaee194b186ae48503e7e8db/data-bind-dialog.png)

4. The **Enter text** step allows only its `Text` field to be data driven so this is the only one listed in the `Binding dialog`. Click on the drop-down next to the  `Text` field and expand the data source columns list. In this scenario the data consists of a single column - the `productName`, so select this one.

   ![choose-binding-column](https://www.telerik.com/teststudio/documentation/assets/ccd11dce3488858c8984eb76705e7c65/choose-binding-column.png)

   > **Tip**
   > <br>
   > <br>
   > See <a href="/features/data-driven-testing/attach-columns-input-values" target="_blank">How to bind a step to a data source column</a> for more details.

5. Confirm the binding with the `OK` button.

   ![confirm-binding](https://www.telerik.com/teststudio/documentation/assets/5c0b0eb1cc5572553f7ab017bff21a25/confirm-binding.png)

6. The step gets updated and hints that is bound to some data.

   ![bound-step](https://www.telerik.com/teststudio/documentation/assets/3b3432ead09dfcec6e99b1235cc67ed1/bound-step.png)

7. 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 `ExpectedString`.

   ![wait-step-bound](https://www.telerik.com/teststudio/documentation/assets/c914557640afbf89223f75d4dcde6a76/wait-step-bound.png)

## Execute the Data Driven Test and Review the Results

Now that the test is configured 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](https://www.telerik.com/teststudio/documentation/assets/fcac8a8d15f8f7732bec1e45004cb55a/execute-data-driven-test.png)

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](https://www.telerik.com/teststudio/documentation/assets/86a6354be3072f5ac9f506bb79b32292/iterations-dropdown.png)

> **Tip**
> <br>
> <br>
> For more information, see <a href="/automated-tests/data-drive-test/ddt-results#summary-results" target="_blank">how to read the results of a data driven test</a>.

## Other data driven scenarios

* <a href="/automated-tests/data-drive-test/external-data-driven-test" target="_blank">Data drive a test using external data source</a>
* <a href="/automated-tests/data-drive-test/multi-level-tests" target="_blank">Test as steps used with data driven testing</a>
* <a href="/automated-tests/elements/find-element#data-driven-find-expression" target="_blank">Data drive the find expression of an element in Test Studio</a>
* <a href="/automated-tests/data-drive-test/data-binding-in-code" target="_blank">Use data source columns in coded steps</a>

## See Also:

* <a href="https://www.telerik.com/blogs/test-studio-step-by-step-data-driven-tests" target="_blank">Step-by-Step: Data-Driven Tests</a>
* <a href="https://www.telerik.com/blogs/test-studio-step-by-step-testing-execution-paths-conditional-tests" target="_blank">Step-by-Step: Testing Execution Paths With Conditional Tests</a>
