Sunday, November 10, 2013

Performance testing on search form

Searching is as important to an e-commerce web site as google is to the internet. With a good, responsive search form, user can quickly find the item/product to purchase or book.

So how should we do performance testing on search form? simply sending HTTP POST or GET request with something like "search_block=examples" may not work, since there may be some hidden fields present in the form data like "search_block=examples&cpId=12001&_sessionId=100012". That's because the form may look like

In the above, "getFormField(http.replyBody)" will parse the form in the http reply body and produce a compound variable with multiple fields, each field has a name and value (if present) from the form. We will assign a value to the "search_block" field and "combine" the fields in the compound variable "a" and create a string like"search_block=examples&cpId=12001&_sessionId=100012".

Of course, to make it more effective, we can read a list of query phrases from a csv file. This is covered in previous blogs and will be left as an exercise for the reader.

In addition to query string, sometimes we need to create a pair of random dates when doing search. This happens, for example, when we reserve a hotel room or air plane tickets. It's quite easy with netgend javascript. Here is an example that shows a random start date is picked between now and 7 days later, an end date date that's 2 days later.

Last thing we cover in this blog is related to "suggestions" in search form. We frequently see some suggestions when we are typing queries. How did the suggestions get to browser? Turns out that behind the scene, there are ajax calls to server to fetch suggestions as user types the characters in the text box.

How do we emulate clients talking to server for suggestions? It's only a few lines on netgend's javascript.