bbondi

http://BB/EmployeeService.asmx/GetEmpID

Headers

String Body

Extraction Rules

Extract Attribute Value

http://BB/employeesubtaxing.aspx

QueryString Parameters

EmpId=2232

I have a Data Source with Employee numbers (3001 - 3100) and I'd like to know what to do with the stringbody below:

{"strUDEmpID":"3001","iCompanyID":"1"}

I think it should be fine to insert the data source like this:

{"strUDEmpID":"DataSource1.CreateNewEmployees_ID_Numbers#txt.Threes","iCompanyID":"1"}

After the request is submitted a new EmpID is returned. If I want to capture that value to use later in the webtest is it done like this:

1. Add a new Extraction Rule after the String Body and give it a name: theNewEmpID

2. The Context Parameter Name is: EmpId (this is what I see in the webtest QueryString Parameters)

3. There are several other fields but I do not think I need to enter data for these! !

Now I can use theNewEmpID in the Form Post sections

I'm not sure about which type of Extraction rule to use to get the value returned! !



Re: Visual Studio Team System - Web and Load Testing Query String Body modifications and Extracting a value

Yutong MSFT

1. Data binding fields in string body

For general information on data binding, please check our FAQ. Use the following string format for the binding{{DataSourceName.DataTable.TableColumnName}}, where DataSourceName is the name of the data source you added, DataTable is name of the SQL table, and TableColumnName is the column you will be using for binding. The {{}} indicate that databinding will be used.

2. Extraction rule

The build-in extration rule Extract Text can be used to extract the field of interest. Specify the context parameter name on the Add Extraction Rule dialog, e.g. EmpID. This will add a context parameter called EmpID to web test context when you run the test. The value of EmpID will be populated after the reqest completes. In your case, you can data bind your query string parameter EmpId to the context parameter {{EmpID}}. After you run the web test, this conext parameter can be found in the Web Test Results Viewer.

If the build-in rule does not meet your requirement, you can write your own extraction rule. For information on Extraction rules, please check our FAQ.

Thanks.






Re: Visual Studio Team System - Web and Load Testing Query String Body modifications and Extracting a value

bbondi

I am not using the database for my data, but a .txt file.

Below is the value I used:

{{"strUDEmpID":"DataSource1.CreateNewEmployees_ID_Numbers#txt.IDnum","iCompanyID":"1"}}

Below is the error I'm seeing:

"not found in test context"

Any clues as to where to go, what to try





Re: Visual Studio Team System - Web and Load Testing Query String Body modifications and Extracting a value

bbondi

The String Body has 3001 embedded in the text which is what was captured:

"strUDEmpID":"3001","iCompanyID":"1"

I have tried to add data binding to this statement but have not found a way to do this Sad

I know this must be a common task, so how do YOU do this





Re: Visual Studio Team System - Web and Load Testing Query String Body modifications and Extracting a value

Yutong MSFT

1. You need to add a data source to your web test

2. Replace "3001" with the {{ ...}} binding string I mentioned in the first reply.

Links related to data source can be found in our FAQ.

Thanks.






Re: Visual Studio Team System - Web and Load Testing Query String Body modifications and Extracting a value

bbondi

Hi,

The issue seems to be the syntax to use. The original string is:

{"strUDEmpID":"3001","iCompanyID":"1"}

The defined data source like this:

DataSource1.CreateNewEmployees_ID_Numbers#txt.ID

Now, do I just insert this between the pair of " " , and add the extra curly braces like this:

{{"strUDEmpID":"DataSource1.CreateNewEmployees_ID_Numbers#txt.ID","iCompanyID":"1"}}

or ...





Re: Visual Studio Team System - Web and Load Testing Query String Body modifications and Extracting a value

bbondi

Request failed: Context parameter '"strUDEmpID":"DataSource1.CreateNewEmployees_ID_Numbers#txt.ID","iCompanyID":"1"'

not found in test context

I've also tried the no quotes around the data source. Each returns the same error.