Troubleshooting
Problem
IBM Rational Robot’s Virtual User (VU) language can be used to extend Robots capabilities. The “match()” function can be used parse or capture data at runtime in order to analyze it or use it elsewhere in the script. This document provides a working example of the match() function in a Virtual User script.
Resolving The Problem
The VU language match() function is often used to capture or parse data at runtime. The syntax is as follows:
int match (pattern, subject [, &arg ] ...)
pattern: A string expression specifying the pattern to match, as expressed in VU regular expression notation. To assign the results of the match to &arg, place the regular expression portion of the pattern in the format (regular_exp)$n, where n is an integer representing the position of the argument.
For example, (regular_exp)$0 places the results in arg1, (regular_exp)$1 places the results in arg2, and so on.
subject: A string expression specifying the string to match.subject is often the read-only variable _response, because you may want to match a certain pattern in your response.
argn: The optional string output variable that contains the results of the match. The number of argn variables must be equal to or greater than the number of (regular_exp)$n, even if some variables are left unassigned.
Here is a working example in which a user is trying to capture a “JsessionID” value at runtime
The JSESSIONID value is sent back by the serer in a response header (as seen below)
"3_0_GA_CP02 date=200808051050)/JBossWeb-2.0\r\n"
"Set-Cookie: JSESSIONID=500570618B06BE909EDD145C95638A10.ybcdrws03; Path"
"=/\r\n"
"Keep-Alive: timeout=15, max=98\r\n"
The match function is used in conjuction with a regular expression to first “find” the value; if it is found it gets stored in a variable and can be used later in the script
{
string MyJsessionID = "";
int result;
}
result = match("Set-Cookie: JSESSIONID=([^;]*)$0", _response, &MyJsessionID);
if (result != 1) {
printf("No Value Found");
}
Was this topic helpful?
Document Information
More support for:
Rational Robot
Software version:
7.0, 7.0.0.1, 7.0.0.2, 7.0.0.3, 7.0.0.4, 7.0.0.5, 7.0.1, 7.0.1.1, 7.0.1.2, 7.0.1.3, 7.0.1.4, 7.0.2
Operating system(s):
Windows
Document number:
622173
Modified date:
16 June 2018
UID
swg21377511