This week I wanted to run a form simulation to populate a website with a lot of information by submitting a form over and over. I know there are bigger testing frameworks like MS Application Center, but I just wanted something lightweight and easy to use. Here is a sample XML definition for loading the form with values:
<?xml version="1.0"?> <autoSubmit url="http://localhost/lab/submitter/test01.aspx"" formID="" submitID="SubmitButton" startNumber="10" maximumRounds="10"> <element id="Name" attributeName="value" value="John" /> <element id="Email" attributeName="value" value="test+{0}@address.com" /> <element id="EmailMe" attributeName="checked" value="false" /> <element id="State" attributeName="selectedIndex" value="2" /> </autoSubmit>
The url to load is defined by the url property and the startNumber and maximumRounds setup the submission loop. The form is submitting either using a formID (not useful in ASP.NET) or submitID (the ID of the button control you want clicked). The <element> tags define the properties that need to be set on the various form elements on the page. Text inputs can be incrimented using the {0} syntax (see the Email element). The incriment could be used to generate unique username or emails or add a little unique text to the end of a form post if you wanted a lot of new threads in a forum app. I'm sure there are a million more uses (some not so legitamate) and a lot of expansion possibilities.
Here's a demo screen:
The application embeds an IE object, loads the page, and when the DocumentComplete event fires, it loads the form with values and submits. It then repeats as many times as you ask it to. If anyone wants to expand on this, email me and I'll send you the source.