Highlighted
Absent Member.
Absent Member.
9243 views

Where to place image and text check in loadrunner scripts

Hi,

I am working on loadrunner11 and facing confusion in placing the text checka nd image check in the web(http/html) script.

Should these checks be placed inside teh transactions as below:

lr_start_transaction("0201__Tools");

web_reg_find("Fail=NotFound",
"Search=Body",
"Text=Compare Up to 3 Cutlery",
LAST);
web_link("Sharpening Tools",
"Text=Sharpening Tools",
"Snapshot=t2.inf",
EXTRARES,
"URL=", ENDITEM,
LAST);

lr_end_transaction("0201_Tools", LR_AUTO);

or it should be placed outside the start of the transaction.

Kindly advise.

thanks and Regards
Ashima Thareja
0 Likes
5 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Where to place image and text check in loadrunner scripts

It should be within transaction
Cheers!

Nvr Blame a day in ur life....... Good day gives "happiness" & Bad day gives "experience" ......
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Where to place image and text check in loadrunner scripts

Thanks for the reply Parkar...
Can you please provide a description as to why it should not be outside and why it should be inside the transactions...as my colleagues are asking me to put these checks outside as per the best practice being followed in loadrunner.
But i am not sure whether they are correct in sayng this.

Thanks and Regards
Ashima Thareja
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Where to place image and text check in loadrunner scripts

If you are ending the transaction with LR_AUTO then I would recomend keeping web_reg_find inside because if the function fails then the transaction would automatically fail.

If you keep it out of the trsnaction then even if the function fails the transaction MAY pass.


The idea of keeping checks outside the transaction is to keep it out of the transaction time. You can also keep it inside lr_stop_transaction and lr_resume_transction to stop the clock when you want to check conditions.

Hope this helps.
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Where to place image and text check in loadrunner scripts

Hi,

The web_reg_find function registers a request to search for a text string on a Web page retrieved by the next action function

It search for a text string for the very next Action function in the script, such as web_url etc. It scans the buffers as they arrive rather than after a page is received â a more efficient script with better performance than web_find.

I have seen in some scenario in application the web_reg_find defined outside are not getting captured when the transaction fails.we are using this for bac-bpm

Cheers!

Nvr Blame a day in ur life....... Good day gives "happiness" & Bad day gives "experience" ......
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Where to place image and text check in loadrunner scripts

You can place the find function within the transaction or outside the transaction. Go through the below sample code to understand the process.
Below code searches for word â googleâ in google home page and if the count is >0 (if word exists) , then transaction will be passed otherwise sends a fail status.
Lr_think_time function we can use to insert some delay for user input actions . While replaying the script , if the think time value need to be displayed in replay log , then the relative runtime settings need to checked . Run time settings ->Think time -> select the Replay Log option

web_reg_find("text=google","savecount=cnt",LAST);
lr_start_transaction("google_homepage");
if(atoi(lr_eval_string("{cnt}"))>0
{
lr_end_transaction("google_homepage",LR_PASS);
}
else
{
lr_end_transaction("google_homepage",LR_FAIL);
}
lr_think_time(5);
Above code will check for the text â google â in home page and if not found the tranasaction fails . In real-time scenario , for ex.we need to run the script with 1000 users , and lets say the transaction fails for around 105 users , then all these 105 users will be dropped down and script continues with rest of the users(1000-105=895 users). And if we want the dropped users to resume , we need to have script handlers for that ,below script does that.
web_reg_find("text=google","savecount=cnt",LAST);
lr_start_transaction("google__T001_homepage");
if(atoi(lr_eval_string("{cnt}"))>0
{
lr_end_transaction("google__T001_homepage",LR_PASS);
}
else
{
lr_end_transaction("google_homepage",LR_FAIL);
lr_exit(LR_EXIT_ITERATION_AND_CONTINUE,LR_FAIL); // this stmt makes the users to continue even if transaction fails
lr_exit(LR_EXIT_VUSER); to exit the Vuser

}
lr_think_time(5);
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.