Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

LoadRunner login script-simple and easy to use

2025-03-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

(. ∀) subscription hi,guy, as a vegetable chicken that has just entered the pit for performance test, here is a login script written by itself, passing parameters with username / password / CAPTCHA. Because the problem of CAPTCHA was not bypassed at that time, the direct access interface was selected to obtain CAPTCHA. The main process is as follows: send verification code acquisition request = > obtain verification code = > fill the verification code into the login request parameters, and send login request = > determine whether the login is successful. (when judging whether the login is successful or not, because the returned code value is used in subsequent tests, I directly judge whether code is used as the basis for judging the success of the operation.) LR's script is based on C language, so here, we must pay attention to the use of each statement at the end of each statement; in the previous process, we briefly described the steps of our scripting. Now let's refine the specific implementation of each part. 1. The API that sends the verification code to get the verification code of the request is a GET request. Using the LR function, you can write parameters directly to web_url ("alias for this request", "URL= interface address", "Resource=0", "RecContentType=json/html", "Referer=", "Snapshot=", "Mode=HTML", LAST). 2. To obtain the verification code, you need to find the parameters stored in the verification code from the returned result in the first step, and then take the verification code out. Put web_reg_save_param ("self-set parameter name", "LB=result\":\ "" / / the leftmost character "RB=\", / / the rightmost character / /" ORD=1 "of the parameter to be stored) in the parameter name you set by yourself. / / the number of times the content that meets the above conditions should be taken as "SaveLen=4", / / the length of the parameter to be stored is "SEARCH=BODY", LAST) / / there are many attributes that you can find on your own. If you run in this order, you are bound to make an error. Because web_reg_save_param is a function that registers types. It registers a request to find and save a text string in the retrieved web page. This operation is performed only after the next action function, such as web_url, is executed. Therefore, in scripting, you need to write the code of step 2 before step 1, fill in the verification code into the login request parameters, and send login request steps 2 and 3 is actually a manual associated operation. The login interface is an POST request. Web_submit_data ("alias for this interface", "Action= interface address", "Method=POST", "TargetFrame=body", "RecContentType=json/html", "Referer= page address", "Snapshot= snapshot", "Mode=HTML", ITEMDATA "Name=loginName", "Value= {loginName}", ENDITEM, "Name=password", "Value= {password}", ENDITEM, "Name=captcha", "Value= {result}", ENDITEM, "Name=type", "Value=H5", ENDITEM, LAST) Note that in "Name=captcha", you should pass the CAPTCHA that we stored above, so the parameter passed is the name of the parameter we set in step 2. That is, "Value= {the parameter names set by myself in step 2}, Value= {loginName} and {password}, I set the parameter list. I'm so tired. I don't want to write today. See you tomorrow! 4. To judge whether the login is successful or not, I need to get the return value. If it fails, I will directly report the wrong No match found for the requested parameter "code". Print the code value for success. Yes, I'm a little lazy. Web_reg_save_param ("code", "LB=code\":\ "", "RB=\", / / "ORD=1", "SaveLen=32", "SEARCH=BODY", LAST) hasn't started yet. By the same token, this registered function should also be placed before step 3. Print using lr_output_message (lr_eval_string ("{code}"))

OK, now that our development manual has been completed, we should pay attention to other details as well.

1. Create a new script and be careful to select the script protocol consistent with the project you are testing. 2. Lr_start_transaction ("login"); lr_end_transaction ("login", LR_AUTO); set the transaction start and end function ("transaction name"). If you need to report transactions such as average transaction response time, you must add transactions. Add transaction functions before and after the statistics you need. Add transaction functions to manual writing functions, and start and end transactions under the insert option. You can directly click add 3. Run Log under Run time setting under the Vuser option can choose the number of runs (not concurrency). OK, I'm a little tired. I'll talk about checking the report next time. PS: this is just a simple login script, and many settings will be slowly shared with you in future documents (^ U ^) YO~.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report