Using standard web vusers to test web services

2010-12-01  张林 

Question: Using standard web vusers to test web services
    Subject: HTML return value
    Hi Stu, you probably know the answer,
    what I need to know if there is an option in Vugen to run a url and to save the url content to a string, something like XML apis in Vugen.
    Later I can parse the string to see if I got the right value.
    There is surely an add-on to web_url to save the return value to a string.
    and I need to save it as a variable in Vugen and not writing it to a file.
    Tell me if you know if it achievable.
    Thanks
    Txxxx

Here is some example code…
// save headers to a parameter
web_save_header(REQUEST, "ParamRequestHeader");
web_save_header(RESPONSE, "ParamResponseHeader");
 
// save entire body to a parameter
web_set_max_html_param_len("262144"); // default max length is 256 characters
web_reg_save_param("ParamResponseBody", "LB=", "RB=", "Search=Body", LAST);
 
// check that page contains expected value
web_reg_find("Text=Google", LAST);
 
web_url("Google",
"URL=http://www.google.com.au/",
"TargetFrame=Main",
"Resource=0",
"RecContentType=text/html",
"Snapshot=t3.inf",
"Mode=HTTP", // If this is HTML, then ParamResponseBody will contain the most recently downloaded item on the page (eg/ a GIF).
LAST);       // but note that this means that the resources referenced on the page will not be downloaded.
// An easier way to do this is to define a left and right boundary around the item that you want to check.
 
lr_output_message("# Request Header:\n %s", lr_eval_string("{ParamRequestHeader}"));
lr_output_message("# Response Header:\n %s", lr_eval_string("{ParamResponseHeader}"));
lr_output_message("# Response Body:\n %s", lr_eval_string("{ParamResponseBody}"));


    thanks stu, look promising, my HTML return code going to be in XML format so I will probably going to use XML api to find a specific values.

If you are using this with web services, you just need to use…
// save entire body to a parameter
web_set_max_html_param_len("262144"); // default max length is 256 characters
web_reg_save_param("ParamResponseBody", "LB=", "RB=", "Search=Body", LAST);


…then you can use the lr_xml functions to extract values from the parameter containing the SOAP body.

http://www.myloadtest.com/web-service-testing-with-standard-web-vuser/
386°/3862 人阅读/0 条评论 发表评论

登录 后发表评论