jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xie, Shawn Y." <s...@Covad.COM>
Subject createing MM/DD/YYYY date string
Date Tue, 02 Nov 2004 07:46:58 GMT
In my functional test plan, I need to assert a page contains today's date string as MM/DD/YYYY
(e.g. 01/02/2004 for Jan 2, 2004) or not.  I tried to use JMeter javascript function to dynamically
generate the date string. It seems JMeter javascript cannot run multiple lines of code (Please
confirm this), I finally end up at an ugly, but close to work solution by defining a variable
name as 'today' and value part as:
${__javaScript((((new Date().getMonth()+1)<10)?('0'+new Date().getMonth()+1):(new Date().getMonth()+1))+"/"+(new
Date().getDate()<10?('0'+new Date().getDate()):new Date().getDate())+"/"+(new Date().getYear()+1900),)}
I said "close to work" as above code does return MM/DD/YYYY as expected but it somehow always
appends with 3 white spaces at the end of it. These white spaces prevents me from using ${today}
in the assertion as in the page the date has no space following it.
What I need your help are:
1. Is there a elegant way to generate MM/DD/YYYY in JMeter?
2. How to trim the white spaces at an javascript return (again in JMeter)?
Thanks a lot for your help in advance.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message