Using SQL Server for Data Driven Web Testing in Test Studio

 

In this post we will follow step by step approach to bind data from a SQL Server table to perform data driven automated web testing.

Let us assume we have a SQL Server table and we want to use it as data source for automated web testing in Test Studio. Assume table schema is as following

image

And data in table is as below

image

Before using data from this table for automated web testing, we need to add database containing this table as data source and then we will have to bind the table to the test. Essentially we need to perform three steps,

  1. Add database as data source in test project
  2. Bind table to test
  3. Bind column to a particular Test step

Add database to project

To add database as data source to project click on Project tab and then click on Add Data Sources

image

Choose Database as type of data source

image

Select SqlClient Data Provider as Provider from then Provider drop down.

image

After selecting provider, we need to provide connection string of the database and a friendly name for the data source. Click on ok button to add SQL Server database as data source.

image

After adding data source you can see that added data source is being listed in the Data Source section.

image

 

Binding Table to a particular Test

Once data source is added to the test project, we can bind a particular table from data source to a test. To do that right clicks on test in which you want to do data binding. In below image we are binding to test named bingtest

image

You will be prompted to select data source. In drop down the entire data source added to the project would be listed.

image

From drop down select data source we added in previous step.

image

Once data source is selected one more drop down would get visible to select table. In this case there is only one table named BingSearch in the data source. Select the table from the drop down.

image

After selecting table all the records from table will be listed in Grid. Click on the Ok button to complete data binding task to a test.

image

You will notice a database icon next to test we done data binding.

image

Binding Columns to a Test Steps

To bind a column to a test step we need to select that particular test step in the Steps tab and from the properties tab select collection option

image

After selecting the step in the property tab navigate to Data Driven section

image

From the collection drop down, you need to select the column to bind to the step. Once column is selected, click on the Set button to complete the data binding.

image

You can verify in the test step that test property of that element is data driven now.

image

In this way you can perform data driven testing fetching data from a SQL Server table. I hope this post was useful. Thanks for reading.

 

Advertisement

4 thoughts on “Using SQL Server for Data Driven Web Testing in Test Studio

  1. This “Friendly Name” how can I reach it from C# code? Because I want to do an insert in the DB with an StoredProcedure.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.