Jump to content


Photo

Include use of variable in Search Parameter Boundries


  • Please log in to reply
1 reply to this topic

#1 Pooja joshi

Pooja joshi

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 13 November 2017 - 11:10 AM

Hi,

 

Search Parameter is very useful function. It becomes more useful if we can use variables for boundaries.

 

So that complex extraction of variables becomes little easier and helpful as it can handle dependency.

 

Warm Regards,

 

Pooja



#2 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 663 posts

Posted 13 November 2017 - 12:57 PM

Hi,

 

You can use JavaScript processing. Here is the code analogous to the “Search Parameter” function:

 

var str = context.responseBody;//input

var left = context.variable("left");//left boundary

var right = context.variable("right");//right boundary

var leftIndex = str.indexOf(left);

var rightIndex = -1;

if(leftIndex != -1)

{

            rightIndex = str.indexOf(right,leftIndex+left.length);

}

if(rightIndex != -1)

{

            str = str.slice(leftIndex+left.length,rightIndex);

            context.variable("str")=str;// return string

}


Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users