Walmart is the largest retailer in the world, it employees 2 million people and has 8,900 stores world wide. Its online presence is quite impressive too. I used it to print out my digital pictures from a cruise trip and was happy with both the quality and the price. One of the things that people do on the web site is to search for items to buy, so searching is absolutely important.
A few points to notice on Walmart's search form:
- use HTTP GET instead of POST
- has multiple hidden fields,
- sometimes all the html are minified, so it's hard to read and do regular expression on
- attribute values are not always surrounded by double-quotes.
function VUSER() {
action(http, "http://www.walmart.com");
a.search_query = "candy";
b = fillHtmlForm(http.replyBody, a, "id", "searchbox");
action(http,"http://www.walmart.com${b.url}?${b.data}");
}
It's not quite realistic due to the hard coded query "candy". Yes, we can remedy it by reading from a file that contains a list of queries, but it is still not realistic enough: when a real user do searching, he/she may limit the search to a particular department, like someone who wants to buy DVD player may search it in "Electronic" department. A more realistic search is to have a file (csv file) that contains a list of items, each item has a department name and a query phrase, like the following: Music,The Bad
Health,vitamin E
Music,Say you say me
Books,the blood line
.....
The challenge is, how do we convert the department names such as "Health", "Music", "Photo Center" into numbers (called "search_constraint"). This is what the NetGend platform supports well. To get the mapping, you just need a function called "mapFormOptions". Here is the syntax.
mapFormOptions(<htmlString>, <optionName>)
With the mapping, say, in variable "options", we can easily find the value of the option, say, "Music" is options.Music, the value of "Photo Center" is options."Photo Center", (note that we need a quote around "Photo Center" because of the space). In general, if a variable "opt" contains an option name, the value of the option is options.$opt.
Here is the script that implements the search.
function userInit() {
var options = {};
var db = fromCSV("searchs.csv");
}
function VUSER() {
record = getNext(db); //record[0] is department name, record[1] is query
action(http, "http://www.walmart.com");
if (hasElement(options) == 0) {
options = mapFormOptions(http.replyBody, "Health"); //"Health" is unique enough
}
a.search_query = record[1];
opt = record[0]; //department name
a.search_constraint = options.$opt;
b = fillHtmlForm(http.replyBody, a, "id", "searchbox");
action(http,"http://www.walmart.com${b.url}?${b.query}");
}
The script is still fairly simple (given all the mapping work it has to do!), with the super scalability of 50,000 VUsers emulated on a box, it can potentially give a good testing on the performance of the searching functionality (we will need to get the permission to run load testing).Walmart's web site is a typical e-Commerce site, if a performance test platform/tool can test it out well, chances are that it may be able to test the other e-Commerce sites well.
No comments:
Post a Comment