[Webtest] how to access properties from groovy

Kazuchika Sekiya Kazuchika Sekiya" <kazuchika@gmail.com
Thu, 11 Sep 2008 14:01:10 +0900


Dierk,

I tried your latter suggestion (the first one didn't fit to my requirement)=
:

>  storeXPath xpath:'//div[2]', property:'result'
>  groovy (replaceProperties:true) {
>    println '#{result}'
>  }

but this didn't work. (just printed "#{result")

According my brief investigation of the source code, the
"replaceProperties:true"
causes org.apache.tools.ant.Project#replaceProperties() method call at last=
,
but the method only process ${} type properties, not #{} dynamic properties=
.

Any other idea?

Thanks,
kazuchika

On Wed, Sep 10, 2008 at 5:39 PM, Dierk K=F6nig <dierk.koenig@canoo.com> wro=
te:
> you can use the dynamic property in trailing 'steps', e.g.
> like in
>
>  storeXPath xpath:'//div[2]/a/@href', property:'result'
>  invoke '#{result}'
>
> In case you want to use the dynamic property from Groovy
> code, you have to use the webtest groovy step, e.g.
> like in
>
>  storeXPath xpath:'//div[2]', property:'result'
>  groovy (replaceProperties:true) {
>    println '#{result}'
>  }
>
> For what you can do in the groovy step
> see http://webtest.canoo.com/webtest/manual/groovy.html
>
> cheers
> Dierk
>
>
> | -----Original Message-----
> | From: Kazuchika Sekiya [mailto:kazuchika@gmail.com]
> | Sent: Mittwoch, 10. September 2008 10:04
> | To: Dierk K=F6nig
> | Cc: webtest@lists.canoo.com
> | Subject: Re: [Webtest] how to access properties from groovy
> |
> | Dierk,
> |
> | Thanks for your help.
> | But does this notation work even in Groovy code?
> |
> | I tried:
> | --
> |   storeXPath xpath:'//div[2]', property:'result'
> |   def result =3D "#{result}"
> |   println result.class
> |   println result
> | --
> | but the output was:
> | --
> | class java.lang.String
> | #{result}
> | --
> |
> | Am I misunderstanding anything?
> | (again I am using pure groovy testcase, this is not in XML code)
> |
> | Thanks,
> | kazuchika
> |
> |
> | On Wed, Sep 10, 2008 at 4:43 PM, Dierk K=F6nig
> | <dierk.koenig@canoo.com> wrote:
> | > with the #{propname} notation, see
> | > http://webtest.canoo.com/webtest/manual/properties.html
> | >
> | > happy testing
> | > Dierk
> | >
> | > P.S. great to see you on this list ;-)
> | >
> | > | -----Original Message-----
> | > | From: webtest-admin@lists.canoo.com
> | > | [mailto:webtest-admin@lists.canoo.com] On Behalf Of
> | Kazuchika Sekiya
> | > | Sent: Mittwoch, 10. September 2008 9:27
> | > | To: webtest@lists.canoo.com
> | > | Subject: [Webtest] how to access properties from groovy
> | > |
> | > | Hi,
> | > |
> | > | I'm trying to write some tests completely in Groovy using
> | > | WebtestCase. Most functions work fine but I have one question.
> | > |
> | > | How can I access to dynamic properties from Groovy?
> | > |
> | > | In my test class (which extends WebtestCase), I did:
> | > | --
> | > |   storeXPath xpath:'//div[2]', property:'result'
> | > | --
> | > | I want to use this "result" property value in my Groovy code.
> | > |
> | > | Thanks a lot,
> | > | kazuchika
> | > | _______________________________________________
> | > | WebTest mailing list
> | > | WebTest@lists.canoo.com
> | > | http://lists.canoo.com/mailman/listinfo/webtest
> | > |
> | >
> |
>