Zepernick David wrote:
>
> ...
> In attempting to incorporate groovy script into our scripts. Groovy code
> doesn't seem to work.
> Eclipse is our IDE , btw .
> Is there a simple example of a Canoo webtest script that incorporates the
> <groovy> tags with simple groovy code that will produce some results that
> I can use to verify that I have everything working properly (somewhere out
> on the internet)? The example on the canoo site didn't work as is.
> ...
Here's an example where I used Groovy to compute a suitable date for a
registration...
<group description="Register with date = birthdate + 5 year -1 day?">
<scriptStep description="Compute date between birthdate and birthdate +
5year" language="groovy">
import java.text.SimpleDateFormat
import java.util.Calendar
// get a handle to the properties
def props = step.webtestProperties
// store property in string
def bd = step.getWebtestProperty( 'de.bbp.datenaissance',
step.PROPERTY_TYPE_ANT)
// convert string to Date
def sdf = new SimpleDateFormat('dd/MM/yyyy')
def dt = sdf.parse( bd)
// do Date + 5 years - 1 day
def cal = java.util.Calendar.getInstance()
cal.setTime( dt)
cal.add( Calendar.YEAR, 5)
cal.add( Calendar.DAY_OF_YEAR, -1)
// convert new Date to string
def dd = sdf.format( cal.getTime())
// store new Date as property ( use #{} to acess it from webtest)
props.putAt('date.tooYoung', dd)
</scriptStep>
<invoke description="Register with date = birthdate +5 -1d"
url="#{currentFlowKey}" method="POST"
content="_eventId=saveEtude&nomEtudeCode=${data.etudes.nom.etude.code}...;dateDebut=#{date.tooYoung}&dateFin="
save="mySaveEtude3" />
<verifyXPath description="Message
'${etudes.error.startDate.upper.birthday}' present?"
xpath='//fo...@id="etudeForm"]//l...@class="errors" and
text()="${etudes.error.startDate.upper.birthday}"]' />
</group>
Regards, Avander
--
View this message in context:
http://www.nabble.com/Looking-for-help-running-Groovy-in-Canoo-Webtest-tp24296109p24677356.html
Sent from the WebTest mailing list archive at Nabble.com.
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest