Evaluate string content in LoadRunner

This little bit of code was passed to bish.co.uk by Mark Sibley. I thought that I’d reproduce it here because it looked useful. You can use this function to check whether a captured string contains a certain piece of text, this allows you to check for the presence of an error “word” when your captured string may not always use the same boundaries.

This gives similar functionality as web_reg_find but without the overhead of searching HTML as it is returned to the vUser, it allows “post processing” of captured text which tends to have a lower performance hit on the vUser.

	// Use this if you want to check whether something you captured contained a piece of text
	// It's handy if the same word appears in more than one type of error or warning message but doesn't // always have the same boundaries.
	if ((char *)strstr(lr_eval_string("{cCapturedString}"), "rejected") != NULL)
		lr_save_string(lr_eval_string("DATA USED:: Rows:[{cRowText}] Param Name:[{sCatParamTitle}] sCatTxt:[{sCatTxt}]"),"sDataUsed");

		lr_fail_trans_with_error("Expected:[%s] %s",Expected,lr_eval_string("Received:[{cCaptured}] User:[{pUserID}] I:[{pIteration}] T:[{sTransaction}] {sDataUsed}")); 
		lr_vuser_status_message(lr_eval_string("User [{pUserID}] completed I:[{pIteration}] T:[{sTransaction}]"));

Author: Richard Bishop