LoadRunner User Verification Code and verification code using scripts

Source: Internet
Author: User
Tags comparison current time md5 md5 encryption ord sprintf strcmp
The Action () {///definition MD5 variable is used to store the string char md5[33] with MD5 encryption;	

	Store the URL that contains user login information char str[174];
	Storing user account information char str1[92];

    Store the current time int t1;
	
	int A;
	Char message[50];

	Put the continuous number of seconds into the T1 variable t1=time ();

	Assign the value stored in the T1 to the time1 variable lr_save_int (t1, "time1"); Use the Lr_eval_string function to get the value of the variable and assign the value to the STR1 variable strcpy (str1,lr_eval_string ("account={code}.pt&appid=1002&code={
	code}&gameid=89&ip={user ip}xtamp={time1}cb29fca01dbtk7a29np0lp59yl6hd258 "));
	Lr_output_message (STR1);
	The STR1 is MD5 encrypted, and the encrypted string is assigned to the MD5 variable getmd5fromstring (STR1,MD5); The URL string that regenerates and contains the value contained in the sign "=" Md5 into the str variable sprintf (str, "url=http://{server ip}/api/character/validatecode?account={

	code}.pt&appid=1002&code={code}&gameid=89&ip={user ip}xtamp={time1}&sign=%s ", Md5); 
		Manually correlate, get dynamic information, and save dynamic information to the message variable Web_reg_save_param ("message", "lb/ic=message\": \ "", "rb/ic=\" "," ord=1 ",

    "Search=body", "relframeid=1", last);
	Start validating transaction lr_start_transaction ("Validation succeeded");

    Lr_start_transaction ("Verification failed"); BeenTake the CAPTCHA packet Web_url ("Validatecode", str,//get the captcha URL link "resource=1", "Reccontenttype=application/xml", "referer="



    , "Snapshot=t5.inf", last);
	Use the Lr_eval_string function to get the value of the variable {message} and assign the value to the Message variable strcpy (message,lr_eval_string ("{message}"));

    Output Message message lr_output_message (message);


    Call the strcmp function to compare the value stored in the Message with "success"//To assign the comparison result to the variable a a=strcmp (Message, "success");

		Determine the value of a, if a==0 "success" if (a = = 0) {//end validation successful transaction, and automatically set the transaction status (PASS or FAIL) Lr_end_transaction ("Verification Success", Lr_auto);

		Put the continuous number of seconds into the T1 variable t1=time ();

	   Assign the value stored in the T1 to the time1 variable lr_save_int (t1, "time1"); Use the Lr_eval_string function to get the value of the variable and assign the value to the STR1 variable strcpy (str1,lr_eval_string ("account={code}.pt&appid=1002&code={
		code}&gameid=89&ip={user ip}xtamp={time1}cb29fca01dbtk7a29np0lp59yl6hd258 "));
		Lr_output_message (STR1);
		The STR1 is MD5 encrypted, and the encrypted string is assigned to the MD5 variable getmd5fromstring (STR1,MD5); The URL string that regenerates and contains the value contained in the sign "=" Md5 into the str variable sprintf (str, "url=http://{server Ip}/api/character/usecode? account={code}.pt&appid=1002&code={code}&gameid=89&ip={user ip}xtamp={time1}&sign=%s ", Md5); Manually correlate, get dynamic information, and save dynamic information to the message variable Web_reg_save_param ("message", "lb/ic=message\": \ "",//The left boundary begins with "message": "" "rb/

		Ic=\ "",//Right border for "" "" "" ord=1 "," Search=body "," relframeid=1 ", last);
		Start using transaction lr_start_transaction ("Use succeeded");

		Lr_start_transaction ("Use failed"); Get the CAPTCHA packet Web_url ("Validatecode", str,//get the captcha URL link "resource=1", "Reccontenttype=application/xml", "	



		Referer= "," Snapshot=t5.inf ", last);
		Use the Lr_eval_string function to get the value of the variable {message} and assign the value to the Message variable strcpy (message,lr_eval_string ("{message}"));

		Lr_output_message (message);


		Call the strcmp function to compare the value stored in the Message with "success"//To assign the comparison result to the variable a a=strcmp (Message, "success");
		Determine the value of a, if a==0 "success" if (a = = 0) {//end using a successful transaction, and automatically set the transaction status (PASS or FAIL) lr_end_transaction ("Use succeeded", Lr_auto);
else{//End Use failed transaction, and automatically set transaction status (PASS or fail) lr_end_transaction ("Use Failed", Lr_auto);		}} else {//end validation failed transaction and automatically set transaction status (PASS or fail) lr_end_transaction ("Validation failed", Lr_auto);
} return 0;

 }

The script uses MD5 encryption and needs to use the Md5.h file

To add a md5.h file to your script, globals.h file

And to add "include" Md5.h "" in Globals.h




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.