Many applications return an error page with HTTP status 200. Without a content check, LoadRunner counts it as a success, and your load test reports fast, "passing" transactions that were really failures. web_reg_find fixes this by checking that the response contains (or does not contain) a piece of text.
Basic use
Like other web_reg_ functions, it registers a check for the next request, so place it just before that request:
web_reg_find("Text=Welcome, {userName}",
"SaveCount=welcome_count",
LAST);
web_submit_data("login", "Action=https://{host}/login", ... , LAST);
If the text is not found, the step fails and the error appears in the log and in the results.
Useful attributes
- Text: the text to look for. You can use parameters inside it.
- TextPfx / TextSfx: look for text between a prefix and a suffix instead.
- Fail=NotFound (default) or Fail=Found: fail when the text is missing, or when it appears, which is handy for error messages such as "Session expired".
- SaveCount: save the number of matches in a parameter instead of failing, so your own code can decide what to do.
- Search: Body, Headers or All.
Handling the result yourself
if (atoi(lr_eval_string("{welcome_count}")) == 0) {
lr_error_message("Login failed for %s", lr_eval_string("{userName}"));
lr_exit(LR_EXIT_ITERATION_AND_CONTINUE, LR_FAIL);
}
Tips
- Check for text that only appears on success, such as a user's name or an order number, not generic text like the site header.
- Add one check per important step, especially after login and after submitting data.
- Avoid very long texts, which break when the page wording changes.
Frequently asked questions
Does web_reg_find slow the test?
A little CPU on the load generator, which is normally fine. Very many checks on large pages add up.
What about JMeter?
Use a Response Assertion on the sampler. The idea is the same.