Tuesday, November 12, 2013

Performance testing on forms

HTML form is an important part of internet, without it, we will not be able to interact with web server, like placing an order, booking a hotel/flight etc.

In previous blog, we talked about performance testing on search forms. But it didn't cover the more complex cases such as select, radio button etc which are typical on HTML forms. In this blog, we are going to focus on these complex cases and show that the netgend javascript function "getFormField()" can easily take care of them.

First let's warm up with something simple, this can be seen as a review of previous blog: suppose we have a form with some text fields to be filled, like "firstName", "lastName", "city", we can generate http request like the following:

In the above code snippet, second parameter to getFormField (in our case "registerationForm") is used to identify the right form in a HTML page. When HTML page only contains one form, you can leave this parameter empty.

Of course, this will be more interesting if the fields are read from a csv file. Suppose we have a file called "users.csv", each of its rows contains first name, last name and city.

Note that it will work for both textfield and text area. The difference from user's point of view is that text field typically has one line, text area can have multiple lines. In HTML, text field and text area are quite different. Luckily, our users don't need to worry about it -- they are taken care of by netgend test platform.

What if the form has radio button? In performance testing we would like to randomly pick a option. Let's suppose, we have radio button with name "vehicle" and it has 4 options: "bike", "car", "pickup", "truck",

Here the variable "a.vehicle.size" holds the number of items for a.vehicle, in this case, it's 4. A good news here: the above code snippet not only works for radio button, it works for "select" field (a.k.a dropdown box) of a form too.

What about checkbox. Checkbox is different from radio button in that user can check zero or more items. So in performance testing, we need to emulate selecting a subset of checkboxes. How do we do this? randSequence(min, max) function can help. It will return a subset of the sequence (min, min+1, ...max). Suppose we have a checkbox group called "area", with items: "n", "nw", "w", "sw", "s", "se", "e", "ne", "c".