CHROMIUM

Welcome to CHROMIUM's very own blog!

Finding text string in response by LoadRunner

Sometimes, when you wish to find particular text string on a screen through code (without ending up in script failure in case of not-found) here is what you can do:

1. Use Savecount in Web_Reg_find
web_reg_find(“Text=my string on Web Tours”, save count = rc1, LAST);

// by now you are total number of occurrences in rc1

 

// Optional Step 2: setting up a bool if text found

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);
}

// Step 3: passing/failing a transaction on the basis of text finding

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);
}

This post was viewed (44) times.

Leave a Reply

Your email address will not be published. Required fields are marked *