[Webtest] Using storeregex to set properties

Dierk Koenig webtest@lists.canoo.com
Mon, 2 Sep 2002 10:33:48 +0200


Hi Charles,

Your observation is correct. <storeregex> does not use the ANT
property mechanism.

The rationale behind this choice was that ANT properties follow
the "immutable" or "value object" design pattern. They do not
allow value changes after initialization.
We thought that <storeregex> should not undermine this contract.
"Dynamic property" is the WebTest term for properties that
may change their values over time.

So, there is no easy solution to your problem.

You could try to write a new TestStep that assigns a
dynamic property to an ANT Property object. The implementation
can make use of the dynamic property just like all TestSteps do
and create a Property object like e.g. <available> does.

After all, I would reconsider the idea of using strings from
an html page for database access. Isn't that a little bit like
"screen scraping" (with all its problems) ?

keep us posted on how your solution emerges
Mittie


> -----Original Message-----
> From: webtest-admin@lists.canoo.com
> [mailto:webtest-admin@lists.canoo.com]On Behalf Of Charles Massey
> Sent: Freitag, 30. August 2002 20:19
> To: 'webtest@lists.canoo.com'
> Subject: [Webtest] Using storeregex to set properties
>
>
> Hi,
>
> Is there a way to use dynamic properties in another target that
> are assigned
> by storeregex
>
> I would like to use the storeregex task to extract a registration
> number so
> that I can save it in my database.  My problem is that even
> through the logs
> say that the value has been assigned to the dynamic property successfully,
> but I can't access it outside the <testSpec>.  Is there a way to
> assign the
> dynamic propery value to a global property?
>
> I was able to verify that 'foo' indeed is getting set.
>
>  [testSpec] Setting dynamic property <foo> to <ransitional>
>
> I imagine that the dynamic property syntax ( #{foo} ) is special to Canoo.
> Why not use standard property values?  (i.e. ${foo} to access
> foo's value).
>
> Can someone help me with this?  This means either I would like to
> be able to
> use #{foo} outside of the <testSpec> or being able to set the dynamic
> property #{foo} to a property that I can use in another target.
>
> Thanks,
> Charles
> ----
> Example script follows:
>
>
>     <target name="register">
>         <testSpec name="Register new user">
>             &sharedConfiguration;
>             <steps>
>                 <invoke
>                     stepid="Registration page"
>                     url="p.tf/registration"/>
>                 <verifytitle
>                     stepid="Registration page reached"
>                     text="Classmates - Registration"/>
>
>                 <storeregex
>                     stepid="Extract 'ransitional'"
>                     text="([a-z]+)"
>                     group="0"
>                     property="foo" />
>             </steps>
>         </testSpec>
>     </target>
>
>     <target name="storeRegex">
>         <!-- sql is used here to store the regex values from
> storeregex -->
>     </target>
>
>     <target name="printRegex" depends="register">
>         <echo message="foo = #{foo}"/>
>         <echo message="foo = ${foo}"/>
>     </target>
>
>
> The output from printRegex is:
>
> printRegex:
>      [echo] how many = #{howmany}
> Property ${howmany} has not been set
>      [echo] how many = ${howmany}
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>