how to validate login transaction

72 views
Skip to first unread message

snehal

unread,
Apr 14, 2011, 4:52:10 AM4/14/11
to LoadRunner
hi..i want to validate the login TXn...On successful it should send
user message to the replay log..On failure it should throw an error
message and abort the Vuser.....when i run the script below it will
always send the lr_output_message(**) even on failing the Vuser log
in.....can anyone help out please?
_____________________________________________________________________________________
Action()
{

int status;

web_reg_find("Text=Web Tours",LAST);

web_reg_save_param("user_id",
"LB=userSession value=",
"RB=>",
"Search=Body",
LAST);
status = web_url("webtours",
"URL=http://127.0.0.1:1080/webtours",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);

//*****************************************************
if (status==LR_PASS) {
lr_output_message ("**LOGIN SUCESSFUL");
}
else {
lr_error_message ("**Error:FAILED TO LAUNCH WEBTOURS...");
lr_abort ();
}

//*****************************************************
lr_think_time(12);

web_reg_find("Text=Web Tours",LAST);
web_submit_data("login.pl",
"Action=http://127.0.0.1:1080/webtours/login.pl",
"Method=POST",
"TargetFrame=body",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/webtours/nav.pl?in=home",
"Snapshot=t2.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value={user_id}", ENDITEM,
"Name=username", "Value=spkar", ENDITEM,
"Name=password", "Value=sridevi", ENDITEM,
"Name=JSFormSubmit", "Value=off", ENDITEM,
"Name=login.x", "Value=0", ENDITEM,
"Name=login.y", "Value=0", ENDITEM,
LAST);
____________________________________________________________________________________
THIS IS WHAT IT SHOW IN THE REPLAY LOG ..EVEN THE LOGIN IS FAILED
Starting iteration 1.
Starting action Action.
Action.c(13): web_url("webtours") was successful, 6453 body bytes,
1724 header bytes [MsgId: MMSG-26386]
Action.c(25): **LOGIN SUCESSFUL
Action.c(35): Registering web_reg_find was successful [MsgId:
MMSG-26390]

Kamran Khan

unread,
Apr 15, 2011, 3:44:00 AM4/15/11
to lr-loa...@googlegroups.com
LR automatically does the same using color coding - it aborts users if they fail transaction unless you over-ride run-time settings and opt "Continue ion error" under Error Handling in Miscellaneous.

I apologize on behalf of this group for late response - as everyone was busy in scolding and throwing weight on others.


Sincerely,


> Date: Thu, 14 Apr 2011 01:52:10 -0700
> Subject: how to validate login transaction
> From: visit...@gmail.com
> To: LR-Loa...@googlegroups.com
> --
> You received this message because you are subscribed to the Google "LoadRunner" group.
> To post to this group, send email to LR-Loa...@googlegroups.com
> To unsubscribe from this group, send email to
> LR-LoadRunne...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/LR-LoadRunner?hl=en

Surendra Ramanapudi

unread,
Apr 15, 2011, 9:54:33 AM4/15/11
to lr-loa...@googlegroups.com, snehal
I can give you some points. TYou can buils on these
 
1. Use Savecount in Web_Reg_find
 web_reg_find("Text=Web Tours", save count = rc1, LAST);
2. int bFindBoolean = TRUE;
bFindBoolean = (atoi(lr_eval_string("{rc1}")) > 0) ? TRUE : FALSE;
 if (bFindBoolean)
  lr_end_transaction(string, LR_AUTO);
 else
 {
  lr_end_transaction(string, LR_FAIL);
}
 
or
3.  if (atoi(lr_eval_string("{rc1}")) > 0)
  lr_end_transaction("xxxx", LR_AUTO);
 else
 {
  lr_message("transaction failed.");
  lr_end_transaction("Login", LR_FAIL);
}
 
 
there are multiple ways
 
 
 
 
Reply all
Reply to author
Forward
0 new messages