To test the performance of a system with a team of colleagues. This system is a service that sends Ajax requests to the background and then calls a third party. The performance of third-party services is not up to our control, so developers have made improvements, and timeouts are returned directly. So on the LoadRunner side, the result is much more beautiful. At that time I did not care, and then a pondering, this is not to say LoadRunner do not check Ajax content on the passage? To validate this assertion, a simple example is made.
The first is to write a front-end HTML, send Ajax to the background, and then write a servlet processing requests, return different content. The script is then recorded and played back with LoadRunner to verify the status of the Ajax content.
Create a new Web project, add an HTML file and a servlet
The HTML content is as follows:
This is a simple simulation of registering the page, Ajax sends the input username into the background.
The servlet handles the code as follows:
protected void dopost (httpservletrequest request, Httpservletresponse response) throws servletexception, ioexception {// todo auto-generated method stubtry {thread.sleep (500);} catch (interruptedexception e) {// TODO Auto-generated catch Blocke.printstacktrace ();} String username = request.getparameter ("username"); Printwriter out=response.getwriter (), if (Username.equals ("Zhangsan")) {Out.print ("existed");} Else{out.print ("registered successfully");}}
When the input user is Zhangsan, AJAX returns a flag that the user name already exists, and in addition returns a hint that can be registered. (To simulate network delay, pause 500 milliseconds)
LoadRunner recorded the following script:
Action () {web_reg_find ("text= user Registration", last) web_url ("AAA", "url=http:// 192.168.1.102:8080/aaa/", " resource=0 ", " reccontenttype=text/html ", " Referer= ", " Snapshot= T1.inf ", " mode=html ", last)//web_reg_find (" text=existed ", last); Web_custom_request (" CheckName ", "Url=http://192.168.1.102:8080/aaa/checkname?username=zhangsan", "Method=post", "Resource=0", "referer=http://192.168.1.102:8080/aaa/", "Snapshot=t2.inf", "mode=html", "EncType=", last)//web_reg_find ("text=registered successfully", last) web_custom_request ("CheckName_2", " Url=http://192.168.1.102:8080/aaa/checkname?username=lisi ", " Method=post ", " Resource=0 ", " referer=http://192.168.1.102:8080/aaa/", " Snapshot=t3.inf ", " mode=html ", " EncType= ", LAST) ; Web_submit_data ("Checkname_3", "Action=http://192.168.1.102:8080/aaa/checkname", "Method=POST", "Referer=http://192.168.1.102:8080/aaa/", " Snapshot=t4.inf ", " mode=html ", itemdata, " Name=username ", " Value=lisi ", enditem, "Name=password", "value=123456", enditem, last); return 0;}
The two lines in the note are manually added, and the content returned by Ajax can be detected.
This article is from the "Empty" blog, make sure to keep this source http://6738767.blog.51cto.com/6728767/1591892
Verifying LoadRunner's checksum of Ajax content