jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kyle McAbee" <k.mca...@treev.com>
Subject RE: question of ${_javaScript} function
Date Thu, 09 Dec 2004 00:43:47 GMT
Dear Avian Liao and JMeter Users:

Here is a list of things I check when a __javaScript function is not working. Number 3 is
probably the solution to Avian's problem.

1.	The function name of __javaScript must start with two underlines. If it does not, JMeter
will not execute the function. All JMeter function names start with two underlines, except
for _StringFromFile, which starts with one underline.
	Right: 	${__javaScript( ... )}
	Wrong: 	${javaScript( ... )}
2.	If a function parameter contains a comma character, you must put the escape character (backslash)
before the comma. That causes JMeter to use the comma as data rather than as a delimiter between
parameters.
	Right: 	${__javaScript('str'.length,Comma\,InData)}
	Wrong: 	${__javaScript('str'.length,Comma,InData)}
3.	To reference a variable in a function parameter, enclose the variable name in single quotes.
	Right: 	${__javaScript('${MyString}'.length,MyStringLength)}
	Wrong: 	${__javaScript(${MyString}.length,MyStringLength)}
4.	You can write an entire small JavaScript program in a __javaScript function. For example,
to get the current date in MM/DD/YYYY format, use the code below. This example shows that
you can declare variables and separate lines with semicolons in the JavaScript code.
	${__javaScript(var d = new Date(); var date = d.getDate(); $DATE = (d.getMonth() + 1) + "/"
+ (date < 10 ? "0"+date : date) + "/" + d.getFullYear();,DATE)}

Sincerely yours,

Kyle

-----Original Message-----
From: Liao, Avian [mailto:aliao@enporion.com]
Sent: Wednesday, December 08, 2004 5:18 PM
To: Jmeter Question (E-mail)
Subject: question of ${_javaScript} function 


Hi, All, 

Anyone has experience passing variable between Jmtere variable and javascript variable?
In my case, I have variable that was extracted by Regex, and I called it "findMe", in function,
I try to use javascript to see if I can reuse this variable or not, so I did like
${__javaScript(${findMe}+123,showJava)}

After all this, I use Java Request to see how is the variable doing between Jmeter and javascript,
and it turns out nothing. Any ideal?

Al

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message