You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by henryd <da...@yahoo.com> on 2008/10/06 18:40:20 UTC
please help with a javascript error
Can you please tell me what is wrong with this function:
${__javaScript(var d = new Date(); var date = d.getDate(); var
t=d.getTime(); var tl=t.length; var subtl=t.substr(0,t.tl-1); $sn =
"p"+subtl;)}${__threadNum}
--
View this message in context: http://www.nabble.com/please-help-with-a-javascript-error-tp19841589p19841589.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: please help with a javascript error
Posted by sebb <se...@gmail.com>.
There are already some JMeter variables based on the time:
http://jakarta.apache.org/jmeter/usermanual/functions.html#predefinedvars
perhaps you could use
p${TESTSTART.MS}
as the variable name.
Of course that will only give a unique value per test.
As to the Javascript - did you check for errors in the jmeter log file?
The easiest way to test Javascript code is probably to use the BSF
Sampler - which supports Javascript (and Jexl).
Having developed the code there, you can then convert it to a
Javascript function call.
But remember to escape any commas in the script:
http://jakarta.apache.org/jmeter/usermanual/functions.html#how
Or I've just discovered that you can define the script as a variable
(e.g. SCRIPT on the test plan, and reference it thus:
${__javascript(${SCRIPT}))
There is no need to escape the commas in the SCRIPT variable, because
the above statement is parsed before the the variable is replaced by
its contents.
On 06/10/2008, henryd <da...@yahoo.com> wrote:
>
> I am using Jmeter 2.3.2. I like to generate a unique string of 13 characters
> (based on the timestamp) and the first character has to be an alphabet. I
> was getting a string with a timestamp and want to extract 12 digits from 0
> thru 12 and like to prefix it with an alpha character (eg: "p").
>
>
>
>
> sebb-2-2 wrote:
> >
> > On 06/10/2008, henryd <da...@yahoo.com> wrote:
> >>
> >>
> >> Can you please tell me what is wrong with this function:
> >> ${__javaScript(var d = new Date(); var date = d.getDate(); var
> >> t=d.getTime(); var tl=t.length; var subtl=t.substr(0,t.tl-1); $sn =
> >> "p"+subtl;)}${__threadNum}
> >>
> >
> > What error message(s) are you getting?
> >
> > Where are you using the script?
> >
> > What do you expect it to generate?
> >
> > Which version of JMeter?
> >
> >> --
> >> View this message in context:
> >> http://www.nabble.com/please-help-with-a-javascript-error-tp19841589p19841589.html
> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
> >
> >
>
>
> --
> View this message in context: http://www.nabble.com/please-help-with-a-javascript-error-tp19841589p19843276.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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
Re: please help with a javascript error
Posted by henryd <da...@yahoo.com>.
I am using Jmeter 2.3.2. I like to generate a unique string of 13 characters
(based on the timestamp) and the first character has to be an alphabet. I
was getting a string with a timestamp and want to extract 12 digits from 0
thru 12 and like to prefix it with an alpha character (eg: "p").
sebb-2-2 wrote:
>
> On 06/10/2008, henryd <da...@yahoo.com> wrote:
>>
>>
>> Can you please tell me what is wrong with this function:
>> ${__javaScript(var d = new Date(); var date = d.getDate(); var
>> t=d.getTime(); var tl=t.length; var subtl=t.substr(0,t.tl-1); $sn =
>> "p"+subtl;)}${__threadNum}
>>
>
> What error message(s) are you getting?
>
> Where are you using the script?
>
> What do you expect it to generate?
>
> Which version of JMeter?
>
>> --
>> View this message in context:
>> http://www.nabble.com/please-help-with-a-javascript-error-tp19841589p19841589.html
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>
--
View this message in context: http://www.nabble.com/please-help-with-a-javascript-error-tp19841589p19843276.html
Sent from the JMeter - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: please help with a javascript error
Posted by sebb <se...@gmail.com>.
On 06/10/2008, henryd <da...@yahoo.com> wrote:
>
>
> Can you please tell me what is wrong with this function:
> ${__javaScript(var d = new Date(); var date = d.getDate(); var
> t=d.getTime(); var tl=t.length; var subtl=t.substr(0,t.tl-1); $sn =
> "p"+subtl;)}${__threadNum}
>
What error message(s) are you getting?
Where are you using the script?
What do you expect it to generate?
Which version of JMeter?
> --
> View this message in context: http://www.nabble.com/please-help-with-a-javascript-error-tp19841589p19841589.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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