anyone use JMeter?

lozina

Lifer
Sep 10, 2001
11,711
8
81
what is the proper syntax for comparing a string value to put into the Condition field of a while loop?

LEt's say I needed to compare a variable called name to "Bob"

simply doing: ${name} == "Bob"
does not seem to work
 

Stuxnet

Diamond Member
Jun 16, 2005
8,392
1
0
You need to use the equals() method... '==' will just perform referential equality.
 

lozina

Lifer
Sep 10, 2001
11,711
8
81
You guys know what I'm talking about? I don't think you can put Java code in this condition field... I tried it anyway and confirmed it does not work:

${name}.equals("Bob") <= does not work
 

wkinney

Senior member
Dec 10, 2004
268
0
0
wtf is this ${name}?
.equals returns true if they are equal, so

String name = "Bob";
while(name.equals("Bob")) {

}

Edit:
Also why is jmeter the topic?
 

Stuxnet

Diamond Member
Jun 16, 2005
8,392
1
0
What in the world are you trying to do? Where are you getting this "${name}" stuff from? Give us a broader snippet of code and a broader idea of what you're trying to do.
 

glinius1

Junior Member
Nov 2, 2013
2
0
0
JMeter's While Controller accepts either a function or a variable.

Either evaluated function or variable should be changed to "false" somewhere, otherwise your test will run forever.

So you need to modify your expression to be:

Code:
${__javaScript("${name}"=="Bob",)}

See How to Use JMeter Functions posts series for comprehensive information on various JMeter functions.