Tuesday, September 11, 2007

Custom Extraction Rules - Extract Drop Down List Form Field

I used the Josh Christie's sample code to make a Custom Extraction Rule to check if a drop down list exists based on its name.

I hope it's correct; I removed the references to index and changed
e.Response.HtmlDocument.GetFilteredHtmlTags("input") to

modified sample code:

Custom Extraction Rules - Extract Form Fields by Index

Here are the sites describing how to add the Custom Extraction Rule to Extract Form Fields by Index:

Josh Christie's blog entry:

MSDN library:

Using the example code from Josh Christie:
  1. right click the project and select Add>Class, enter a name, and click OK
  2. double click the .cs file to open and replace text with sample code from here
  3. build the solution
  4. open a web test and the new extraction rule is available

Extraction Rules - Extract Form Field

This type of Extraction Rule is used to verify Form Fields exist on the page. Use an Internet Explorer add-in utility to find the form field names.

Here is the download site for the Internet Explorer Developer Toolbar:

Steps to find the form field names:
  1. View Developer Toolbar
  2. View DOM
  3. Find>Select Element by Click (under the menu of the window in the lower half of the screen)
  4. Click on the control to be tested
  5. Find Name, double click in the Value column, and Copy the text under the Value (in the middle section)

Add the form field to an Extraction Rule
  1. Add an extraction rule to the web test
  2. Select Extract Form Field
  3. Enter a descriptive name under Context Parameter Name (user defined name)
  4. Paste the Form Field Name copied from the DOM Explorer

Form Post Parameters - requires Name - cannot use ID

I have a script written using the Ruby library Watir. I couldn't upgrade it to VSTS because the form fields cannot be accessed by ID in the VSTS Web Test.

There is a testing exercise on Elisabeth Hendrickson's site:

Here's what the Ruby script does
1) click draw with nothing in the sides and verify the triangle type is Invalid
2) enter the same value in all 3 sides, click draw, and verify the triangle type is Equilateral
3) enter values to generate a Right triangle, clcik draw, and verify triangle type is Right
4) enter values to generate a Scalene triangle, clcik draw, and verify triangle type is Scalene
5) enter values to generate a Isosceles triangle, clcik draw, and verify triangle type is Isosceles
6) enter non numeric values in all 3 sides, clcik draw, and verify triangle type is Invalid

The command in Watir is ie.text_field(:id, "side1").set("eee")

In VSTS the Name of the Form Post Parameter is required to set the value.

Retest bug fixes

I am writing web tests that will retest bug fixes in the next version of a reporting application. There's not a good way to retest some of the bugs I found.

Example: unable to check if a control exists when items missing from the report selections unless the name of the control is known. This test will be added after the controls are added.

Another Example: the reports are opened as a pdf in a new window. I don't know how to verify the contents of a pdf file. I tried using the Fiddler utility and saving the file to disk, but none of those requests were captured.

Monday, September 10, 2007

TimeoutException Internal Error! failed to acquire a ReaderLock

I ran a group of web tests from a Test List and got an error on cancel:

Here's a post from the MSDN forum that says to increase the timeout setting in the testrunconfig under Test Timeouts:

Test Data Generation

Here's some sites to help generate test data.

Joe Strazzere has a blog post with strings used to check field lengths:

James Bach wrote a Perl script to generate self describing data strings:

Graham King has a script to generate fake credit card numbers in Java and Python. Includes credit card types: Mastercard, VISA 13 digit, VISA 16 digit, AMEX, Discover, Diners Club / Carte Blanche, enRoute, JCB 15 digit, JCB 16 digit, and Voyager. Credit Card Number Generator:

Benjamin Keen's site allows you to select the fields used in the data file:

This site will send you a list of fake names, but you have to e-mail a request. They sent me csv file containing 3000 people. Fake Name Generator:

Validation Rule - prohibited text

The Validation Rule can be set to fail a test when prohibited text is found on the page. I used this to fail when the message "error running report" is found.
  1. Add Validation Rule
  2. Find Text
  3. Enter Text to search for and set Pass If Text Found = False
Here is the message if the forbidden text is found:

"The prohibited text 'There was an error running the report.' appeared in the HTML response. FindText=There was an error running the report., IgnoreCase=False, UseRegularExpression=False, PassIfTextFound=False"

(select the row that fails in the test results and click the Details tab to view the error)

Friday, September 7, 2007

Data Source - Choose Tables dialog not updated

I posted yesterday that new text files are missing from the Choose Tables dialog.

I missed a key step; the text file is not missing until you add a second data source.

I modified my post to Microsoft, sent them a test project, and attached a video of the steps.

Modified Steps to Reproduce:
  1. Add a Data Source to a web test and save
  2. Create a new text file and Save All
  3. Add another Data Source to the web test and attempt to select the new text file.
The new file is not being added to the Choose Tables dialog until you exit and reopen Visual Studio. The same thing will happen when files are deleted.

Thursday, September 6, 2007

Data Source - new text file missing from Choose Tables

New text file is missing from the Choose Tables dialog until you exit and reopen Visual Studio.

Here's what I've been doing as a workaround: create the web test, create the text file, close Visual Studio, open solution, and add a new Data Source to the web test

I also tried Save All then reopen the solution, but that didn't work.

I reported this as a bug to Microsoft today:

Clearing requests in the web test recorder

Clicking the X in the Web Test Recorder will clear all requests and comments from the test.

I incorrectly thought you could select one request to only delete one line.

Adding comments when recording a web test

You can add the comments as the test is being recorded. I was adding comments after the test was finished and they weren't very good.

Just remember to add the comment first.
  1. Click the folder button in the recorder pane
  2. Enter the comment describing the next set of events and click OK
  3. Click the button or whatever needs done

Wednesday, September 5, 2007

Virtual Tech Ed and other sites

Here's a couple of sites to check out:

Copy Paste Requests in a recorded web test

New request is pasted above selected request

Select the top node or Web Test name and paste to add the copied request to the end of the list


invalid date

To add copies of the 3 requests for page1 and modify them for page2:
  1. Select the first page1 request, right click, and Copy
  2. Select the Invalid Date top node, right click, and Paste
  3. Select the second page1 request, right click, and Copy
  4. Select the Invalid Date top node, right click, and Paste
  5. Select the third page1 request, right click, and Copy
  6. Select the Invalid Date top node, right click, and Paste
Now there are copies of the last 3 requests

Change the properties and Form Post Parameters to work with another page

Select a different request and paste to add a copy above the selected request

There should be a way to change the order of the Web Requests. What if you record steps in a certain order and then want to change them later?

Tuesday, September 4, 2007

Delete Test Results

The test results can take up a lot of disk space if you're not careful. I had a test project where the results directory took up 4GB.

Here's how to delete the test results in VSTS:
  1. Open the test project
  2. Click Test Runs tab in the lower portion 4 tabs after output window
  3. Click the Select drop down list
  4. Select last item "Local or Connect to remote"
  5. Select 2nd radio button "Select results from local test runs" and browse if needed, but it should default to the results of the currently loaded project, and click OK
  6. Select the result from the tree
  7. Connect if needed
  8. Click the X to delete the selected test run and results
Here's the MSDN reference:

I also deleted the contents of the results directories through Windows Explorer. The results are stored in a file with a .trx extension under C:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\TestProject\TestResults (I don't know if this way is correct, but it took less time than trying to delete the result of each run through Visual Studio.)