Creating WebTest in Visual Studio Team System 2008


Creating WebTest in Visual Studio Team System 2008

We can create Test Project using Visual Studio Team System 2008 in that we can add different type of Tests like Web Test, Load test, Unit Test etc.

What is WebTest?

WebTest comprises a series of HTTPRequest. We can see the response which comes from the server and we can use different extraction rules to grab hold of any information from the referrer response that we may need to pass in to the next request. WebTest offers a kind of test with which we can capture/record the HTTP/HTTPS traffic of our website or web server which communicates on HTTP Protocol.

How to Record a WebTest?

First of all we have to create a new Test Project or add a Test Project to Existing Web Application.

clip_image001

Click New Project

clip_image003

Click OK to add the project in the solution.

clip_image004

Adding Web Test to the Test Project – Right click on the Test Project and then Add –> Web Test

clip_image005

Once we click on Web Test menu, Internet Explorer will open with additional tool (Web Test Recorder).

Enter the website address and press Go. It will start recording the test.

Start navigating the site.

clip_image006

Some entries will get added while navigating to the site. Once the navigation is over click on Stop button to stop the recording.

clip_image007

Now Web Test has been recorded. We can enhance the Test by doing parameterization, by adding validation rules etc.

Now we will Test the Web Application using different User ID and Passwords

clip_image008

Add the Data Source –> Right Click on WebTest –> Select Add Data Source

clip_image009

We have three options to set the Data Source Database, CSV File, and XML File.

We can select any Data source based on  data availability.

Here we are going to select Database.

clip_image010

Create new connection by click on New Connection button or Select the Connection from the Combo box if the Connection is already configured in the Project.

Click Next …

clip_image011

Select the login table and Click Finish.

clip_image012

Database will get added in the Test.

 

clip_image013

Here can we assign the Dynamic value(which will come from the database) to the control by selecting Properties.

Select the control (eg. txtUserName) Right Click on it –> Select Properties

 

clip_image014

In properties – Select Value –> Click on the arrow –> Expand DataSource1 –> Expand logindetail table –> select Uname column since we are binding txtUserName textbox with uname column of the database.

Same procedure to be followed for the txtPassword also.

 

clip_image015

After setting the value the fields they will look this.

 

clip_image016

Since we have configured the database to run the tests as many times as records are available in the login table. By default the test will be running once. We have to change the setting to change Number of run iterations.

To change the iterations setting we have to select the Properties of the LocalTestRun.testrunconfig file which will be available in the Solution Explorer.

 

clip_image017

Select Web Test from the List box available in the left side, Click on One run per data source row option of the Number of run iterations group box. Click Apply –> then Close.

 

clip_image018

Now we can start running the Test by click the Run Icon available in the toolbar.

 

clip_image019

In logindetail table we have total 7 records so total 7 times test has been iterated.

Run 3, Run 4, and Run 6 have failed because the logindetail table is having wrong username or password for these records.

 

clip_image020

Now we its time to generate the code for the same WebTest by right clicking on the WebTest1 –> Click on Generate Code..

 

clip_image021

Once the Generate Code is clicked WebTestCoded.cs file will get added in the Project. We can manipulate the code for enhancing the Test.

Link to Download the Code.

Advertisements

4 thoughts on “Creating WebTest in Visual Studio Team System 2008

  1. Hi,

    Can you please help me in implementing validation rules for vsts 2008 webtesting.

    i am also having trouble in data binded webtest for matrix count.
    Like uploaded 2 csv files. datasource1, having 2 row for credentials (username & password)
    datasource2, containing 8 rows for various input combination for search fields.
    I want 2*8 = 16 iterations means 8 iterations for 1st login row than 8 iterations for 2 login row.

    I m getting 8, tried all combination of sequential, random & Unique.

    Please help me out .
    this is my new job n i m nt able to deliver it on time.
    Got your ID on wordpress blog site.

    Thanks in advance.
    Priyanka

  2. Hi Priyanka,

    Follow below link to know How to: Add a Validation Rule to a Web Test
    http://msdn.microsoft.com/en-us/library/ms182544(VS.90).aspx

    and if you want to loop inside a webtest there is no direct way to do this. you have to generate the code for WebTest and you have to implement the looping…
    see the below given link for more details

    https://mscoder.wordpress.com/2010/06/29/calling-webcodedtest-inside-a-webcodedtest-using-vsts-2008/

    Let me know if you have any other query.

    Happy Learning 🙂

  3. Hi

    I have correlated one dynamic value(id:182) as string. but i want to do the math calculation on this(i.e 182+1) and i have to pass this value for the next transaction. can anyone help me on this?

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s