LoadRunner Recording Login operation

Source: Internet
Author: User

Script Business Flow: Visit the Discuz Forum Home--Login Forum--Exit the forum. Use the LoadRunner11 version this time.

First, recording script note

1, to ensure that the Discuz forum on the server to operate normally.

2. Before recording, try to visit Discuz forum to register a test user.

3, select the recording protocol, Discuz forum is a b/s architecture of the web forum, using the Common Protocol "web (http/html)" recording.

4, the setting of recording options, pay special attention to the recording of the http/html level when the choice is "html-based script" or "URL-based script", here Select "html-based script."

5, after recording the script, first save the script, and then play again.

Second, optimize the script

Scripts that are recorded with LoadRunner often require refinement of the script. Here only shows the login part of the action, the optimized script is as follows:

Action_login ()
{

Lr_think_time (12);

Add a collection point login
Lr_rendezvous ("login");

 //Set Start transaction
 lr_start_transaction ("login");
 
 web_submit_data ("member.php",
   "Action=http://127.0.0.1/discuz/upload/member.php?mod=logging&action=login&loginsubmit=yes &infloat=yes&lssubmit=yes&inajax=1 ",
  " Method=post ",
  " reccontenttype= Text/xml ",
  " referer=http://127.0.0.1/discuz/upload/forum.php ",
  " Snapshot=t2.inf " ,
   "mode=html",
  itemdata,
   "Name=fastloginfield", "Value=username", Enditem,
   "Name=username", "Value={username}", Enditem,
   "Name=password", "value={ Password} ", Enditem,
  " Name=quickforward "," Value=yes ", Enditem,
  " Name=handlekey "," Value=ls ", Enditem,
  last);

Output parameterized log information
Lr_output_message ("Login Username:%s", lr_eval_string ("{username}"));
Lr_output_message ("Login Password:%s", lr_eval_string ("{password}"));

Web_add_cookie ("mlmh_2132_checkfollow=1; domain=127.0.0.1 ");

Web_add_cookie ("mlmh_2132_lastact=1399082672%09forum.php%09; domain=127.0.0.1 ");

Web_add_cookie ("Mlmh_2132_checkpm=1; domain=127.0.0.1 ");

Set Association correlation comment-do not change! Original value= ' 935343df ' Name = ' correlationparameter_1 '
WEB_REG_SAVE_PARAM_EX (
"Paramname=correlationparameter_1",
"Lb=formhash=",
"Rb=\" > Exit ",
Search_filters,
"Scope=body",
"Requesturl=*/forum.php*",
last);


Add a text checkpoint to check whether the logged-on user Yuxiuquan is logged in
Web_reg_find ("Text=yuxiuquan",
last);


Web_url ("Forum.php_2",
"Url=http://127.0.0.1/discuz/upload/forum.php",
"Resource=0",
"Reccontenttype=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=html",
Extrares,
"Url=static/image/common/background.png", Enditem,
"Url=static/image/common/nv.png", Enditem,
"Url=static/image/common/search.png", Enditem,
"Url=static/image/common/arrwd.gif", Enditem,
"Url=static/image/feed/friend_b.png", Enditem,
"Url=static/image/feed/favorite_b.png", Enditem,
"Url=static/image/feed/thread_b.png", Enditem,
"Url=static/image/feed/magic_b.png", Enditem,
"Url=static/image/feed/medal_b.png", Enditem,
"Url=static/image/common/tip_bottom.png", Enditem,
"Url=static/image/common/style_switch.png", Enditem,
"Url=static/image/common/user_online.gif", Enditem,
"Url=static/image/common/qmenu.png", Enditem,
"Url=static/image/common/nv_a.png", Enditem,
"Url=static/image/common/pt_item.png", Enditem,
"Url=static/image/common/chart.png", Enditem,
"Url=static/image/feed/task_b.png", Enditem,
"Url=static/image/common/scrolltop.png", Enditem,
"Url=static/image/common/titlebg.png", Enditem,
"url=http://cp.discuz.qq.com/tips/get?rand=310&s_id=&product_version=x2.5&product_release=20120413 &fix_bug=25000000&is_founder=&s_url=http%3a%2f%2f127.0.0.1%2fdiscuz%2fupload%2f&last_send_time =&ts=1399082672&sig=&admin_id=0&group_id=10&open_id=&uid=2&callback= Discuztipscallback ", Enditem,
last);

Set End transaction
Lr_end_transaction ("Login", Lr_auto);

return 0;
}

1, transaction settings, start and end transactions must be the same name, the transaction must be set up in pairs, that is, there are start transactions have to end the transaction, start the transaction should be placed at the beginning of the script, the end of the transaction at the end of the location, but do not think time (lr_think_ Time function) between the start of the transaction and the end of the transaction. In fact, setting up transactions, which can be set in Run_time settings, can be set to "define each operation as a transaction", or to "define each step as a transaction," as needed. I am here to manually set the script myself.

Use function: Lr_start_transaction ("Transaction name");

Lr_end_transaction ("Transaction name", Lr_auto);

2, checkpoint settings, LR checkpoint is divided into text checkpoints and image checkpoints, the way to add checkpoints is simple, in the LR tree view, open the View login page, select what needs to be checked (text or images), and right-click to select "Add Text Checkpoint (Web_reg_find ())" , to manually add checkpoints, you need to set the checkpoint before returning to the page. Finally, add a checkpoint in the script to change the setting in Vuser->run-tme settings, and check the Enable Image and text check.

Use functions: Web_find () or web_reg_find () or Web_image_check (), respectively, described below

(1) Web_find ()

Parameter examples: web_find ("Web_find", "Righof=a", "Leftof=b", "What=name", last);

Parameter interpretation: "Web_find" defines the name of the lookup function, and "Leftof" and "righof=" define the right or left of the lookup character

boundary; "what=" defines the lookup content.

(2) Web_reg_find ()

Parameter examples: web_reg_find ("Search=body", "savecount=ddd", "test=aaa", last);

Parameter explanation: Search is used to define the lookup range, Savecount defines the lookup count variable name, which can be recorded in the slow

The number of occurrences of the found content in the save, which can be used to determine whether the content being looked for is located.

(3) Web_image_check ()

Parameter description: Web_image_check ("Web_image_check", "alt=", "src=", last);

Parameter interpretation: The value of "Alt" and "SRC" directly takes the value of the corresponding parameter in the page's source code.

3, parameterized settings, LR recording login script, the general needs of the parameterized script in the login user and the corresponding password, in order to more realistically imitate the system's business operations. parameterized settings, click on the toolbar icon to open the parameter list, or click on the menu "vuser--parameter list", or use the shortcut "Ctrl+l", click New, define the parameter name username and password, create the table and enter the content

After that, it is particularly necessary to note that the parameter name username and password should be set, which is set by the method of data in the parameter list and by the update value, and the username parameter should be corresponding to the password parameter

Correct, script playback to simulate user logon success, as shown in figure:

(1), username parameter name setting

(2) password parameter name setting

(3), parameterized settings, "Select next Row" and "Update value on" The combination of the two properties, resulting in nine combinations, each way is different, parameterized results are not the same, the following is the parameter value method description

Select Next row:
Sequential: Each vu reads in order. Each virtual user will read in the same order.
Random: Each vu randomly reads one.
Unique: Each vu order takes a unique value. Note: You must note that the data pool has sufficient data to use this type.
Same line as a parameter (for example, name): And the previous defined parameter name takes a peer's record. Usually used in relation to the data above.
Update value on:
Once use the same value only once in all iterations
Each iteration to a new value each time it repeats
Each occurrence only finds the parameter to be fetched again, that is, if there is more than one argument in an action, a value will be fetched each time it is encountered.

(4), in the script, select the script that needs to be parameterized, the right mouse button "Use existing parameters" to choose the corresponding parameter name to parameterize.

(5), output parameterized log information in the script

Output parameterized log information
Lr_output_message ("Login Username:%s", lr_eval_string ("{username}"));
Lr_output_message ("Login Password:%s", lr_eval_string ("{password}"));

4, association settings, because my LR tool Set the association rules in the recording, in the script can use the Automatic Scan Script association value shortcut key CTRL+F8, the scan result toggles the tree view, can see as shown

Click "Association" to return to the script page, as shown in

Replay the script again and see that the associated function was executed successfully in the menu view-test results.

5, set point settings, set Point settings in the menu "insert--set" can be named after the set name, see can understand. Also note that the collection point is placed in front of the starting transaction, behind the think Time (Lr_think_time function).

Use function: Lr_rendezvous ("collection point Name");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.