Coded Webtest and looping thru a datasource?
Coded Webtest and looping thru a datasource?
Hello, I am have a little problem and need some help. I have created a webtest which loops thru a datasource. Converted it to a coded webtest to do some validation but can not get it to loop thru the datasource. 
Is there anything that I am missing
Any help would be much appreciated. 
Thanks
Coded Webtest and looping thru a datasource?
BarryIOS
Try the following and see if it works:
1) Modify the run configuration to have the number of runs you want as described earlier.
2) Open test view. Click the Test menu on the top menu bar, then select Windows and select Test View.
3) Select your coded test in the test view window.
4) Right Click on your test and choose run selection
This will open the test result window and run the coded test. When the test result window indicates the test is complete, double click to open the result.
Draggi
Bob Black
If you mean that you are not seeing the datasource advanced when running the coded test, then you need to run multiple iterations of the coded test. By default the data source access method is sequential. This means that we will start with the first row of the datasource and move forward one row at a time. If you are running the coded test for one iteration, then we will always use the first row in the datasource. If you run the coded test for multiple iterations, then you will see more than one row used from the datasource. You can run multiple iterations by doing the following:
1) Open the Run configuration editor by Clicking on the Top level Test menu, then choose Edit Test Run Configurations, then choose the availble run configuration.
2) Click on the Web Test Tab
3) Change the number of iterations for a webtest. You can either choose a fixed number of iterations or choose to execute one iteration for each row in the datasource.
4) Save the run configuration
5) Run the coded test
Or do you mean that you want to advance the datasource cursor from within one test iteration If so, then you can call the MoveDataTableCursor method when you want to move to the next row in the datasource. The call looks like
this.MoveDataTableCursor("DataSource1", "Products");
In the above line, DataSource1 is the name of the datasource and Products is the name of the table.
Eadd
Unfortunately, you found a bug. The 'one run per data source row' works correctly for the non-coded webtests, but as you found is not currently working for coded tests.
Nugget
AlinaMaria
Ed.
sgaap
I have done steps 1 thru 5 and it works for the webtest1.webtest but not for the webtest1Code.cs.
I can get the run configuration to work with the data source but when I click generate code. A new file is created called webtest1Code.cs.
I delete the webtest1.webtest and then I tried to get the webtest1code.cs to loop thru the data source but for some reason it only does one iteration.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Madhu Sudhan
Ok, I can get the show details page to displays for that webtest.

I do not have the option to change the run setting from a 'fixed run count' to the other option called 'one run per data source row' because that option is grayed out.
I do notice that If I change the fixed run count that it does loop thru the datasource.
I can get it to loop thru the datasource!
Their is one problem that I noticed is that I have to know the numbers of records returned to get it to work correctly. If the fix run count is greater than the recordset count then the recordset start from the beginning again. Is there any way that I can just use the other option called 'one run per data source row'
Thanks