[Webtest] Using storeregex to set properties

Dierk Koenig webtest@lists.canoo.com
Wed, 4 Sep 2002 09:33:24 +0200


Hi Charles,

Great, you did it!

Feel free to send me your code so that I can merge it into the
codebase.

cheers
Mittie

> -----Original Message-----
> From: webtest-admin@lists.canoo.com
> [mailto:webtest-admin@lists.canoo.com]On Behalf Of Charles Massey
> Sent: Dienstag, 3. September 2002 23:38
> To: 'webtest@gate.canoo.com'
> Subject: RE: [Webtest] Using storeregex to set properties
>
>
> Dierk,
>
> Thanks for your help.  I ended up creating a new TestStep as you suggested
> and it works the way I need it to.  The tricky part was getting
> the Project
> so I could set the property from my step.  I'm able to do this by passing
> the Project into the TestContext then accessing the project through the
> context when I need it.
>
> For example:
>
> protected void doExecute(TestContext context) throws Exception {
>     // ...
>     logText(context, "Setting project property <" + fProperty + "> to <" +
> propertyValue + ">");
>     context.getProject().setProperty(fProperty, propertyValue);
> }
>
> I understand your reasons now for choosing to have steps set only dynamic
> properties.  However it might be useful in some cases to have
> steps save to
> a global project property, like in my case in using storeregex.
>
> Would you consider in the future possibly allowing users to set the
> resulting value to an Ant project property?
>
> Charley
>
>
>
> -----Original Message-----
> From: Dierk Koenig [mailto:dierk.koenig@canoo.com]
> Sent: Monday, September 02, 2002 1:34 AM
> To: webtest@gate.canoo.com
> Subject: RE: [Webtest] Using storeregex to set properties
>
>
> 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
> >
>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>