The LR test logs on after the operation to bypass the login

Source: Internet
Author: User

Oadrunner Web_add_cookie

Previous/Next 2011-08-12 09:59:29/personal Category: LoadRunner

View (1287)/comment (1)/Rating (5/0) Web_add_cookie This function is really able to escape the login, haha, this is struggling with my problem ah.

Function prototype: int web_add_cookie (const char *cookie);

Where the cookie parameter list format is added as follows:
Defines the cookie to add or modify. The Cookie parameter has the following format:
Name=value; (required)//The cookie variable name that needs to be added = variable value, must have
Domain=domain_name; (required) A domain name that requires a cookie must have
Expires=date; The expiration date can be no, preferably there.Wrong, the field is set according to the server, the server settings can be stored for how long, how long to save, LR in the simulation when the time is generally allowed in the service side of the time range, but does not seem to be in the scope of the error, estimation will not be useful, and some cookies are based on the session, For example, the cookie is valid for the end of session, meaning that the session is dead and the cookie expires, so it is useless to set it up for a long time.
Path=path; (Default path is "/") cookie path, which is the current path or root directory? Where exactly is this/directory?Neither , the path path means the scope of the cookie, or the cookie is applied from the root directory of the program. This is also to be based on the server settings, look at the path is/, it means that the cookie from the root of the application to apply, LR in accordance with this setting, of course, can also be set to the directory below the root directory, but your client how to know the root directory below the directory? Haha, so this can copy the directory returned by the server.
To use, run an actual login process in the Firefox browser, open the Httpfox plugin during the login process, get the value of each field received by the cookie, and add it to the initialization of LR (Vuser_init ()) to bypass the login.
The code is as follows:
Web_add_cookie ("TONIDO-LOGIN-SEED-10001=588831E0-2D20-43BF-8AAD-979590571E68; path=/; Expires=wednesday, 09–nov–2011 23:12:40 GMT; Domain=kortide.tonidoid.com ");

Web_add_cookie ("TONIDO-LOGIN-HASH-10001=DF420FA77E1FACF1C5AD1D3DE3B5EE007BFFCF09; path=/; Expires=wednesday, 09–nov–2021 23:12:40 GMT; Domain=kortide.tonidoid.com ");

Web_add_cookie ("[email protected]; path=/; Expires=wednesday, 09–nov–2011 23:12:40 GMT; Domain=kortide.tonidoid.com ");

Parameters in the value of the name,value,path,domain can be obtained directly from the Httpfox, as for expires you can write casually, as long as the future time can be. specific to see Kazakhstan.
After adding cookies, those who need to log in before the operation, no longer have to log in and then operate, because the login is too time-consuming, TestWhen encountering tonidoid can only log on 5 users at the same time limit, I want to do more than 5 users of the concurrency scene, has been simulated not come out, this should be able to solve, a try.
It's true, it's settled, haha.

Http://tbaike.com/index.php?category-view-6.html a test-class web site

Another attempt was made to write a function that automatically gets the cookie for the page to change back:

int login (char cookies[10][100])
{
Char cookie[50]; The formatted value of Outflightparam
int len,i;
Web_reg_save_param ("Cookie",
"Lb=set-cookie:",
"Rb=httponly",
"Ord=all",
"Search=headers",
last);
Web_custom_request ("Loginprofile",
"Url=http://url",
"Method=post",
"Resource=0",
"Reccontenttype=text/xml",
"Mode=html",
"Enctype=text/plain; Charset=utf-8 ",
"Body=profile={profile}&safemode=0&autologin=1&password={password}",
last);
Len=atoi (Lr_eval_string ("{cookie_count}"));
for (i=1;i<=len;i++) {
sprintf (Cookie, "{cookie_%d}", i);
sprintf (Cookies[i-1], "%s", lr_eval_string (cookie));
Lr_output_message ("cookie%s", cookies[i-1]);

}

Result ok~~

The header containing the cookie is generally as follows:
(Status-line) http/1.1 OK
Cache-control Private, No-cache, No-store, proxy-revalidate
Connection Close
Content-length 102
Content-type Text/xml; Charset=utf-8
Date Tue, 06:10:10 GMT
Pragma No-cache
Set-cookie tonido-login-seed-10001=fee60fe9-a70d-4936-aeac-64f27fdc21a2; path=/; HttpOnly
Set-cookie tonido-login-hash-10001=9a82fb6088db8b05fa4e6f6b973c28d02383c954; path=/; HttpOnly
Set-cookie [email protected]; path=/; HttpOnly



Httpfox Interception of Cookies

The LR test logs on after the operation to bypass the login

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.