[Webtest] Re: targetB depends on targetA. how to continue session from one target to another ?

Mike Danifo webtest@lists.canoo.com
Wed, 11 Jan 2006 03:04:41 -0500


Sorry - here is the original post and response

Dierk Koenig <dierk.koenig@...> writes:

>
> Hi Marco,
>
> great you care about your test code!
>
> Each testSpec opens a new session.
> Therefore you cannot use the ant features as you are trying to.
>
> In your case building "modules" is the way to go.
> Modules can be realised with xml entities. &definition; and &config; are
> examples.
> Make a new file
>  "login.xml"
> place your code
> =09=09<invoke stepid=3D"login screen"
>                 url=3D"WelcomeForm.aspx"
>                 save=3D"LoginScreen"/>
>               <verifytitle  stepid=3D"verify title"
>                 regex=3D"true"
>                 text=3D"Welcome"/>
>              <verifytext stepid=3D"verify Join Up link on page"
>                 text=3D"Join Up"/>
> into that file.
>
> Refer to that module like
> =09<testSpec name=3D"${testid}">
>         &config;
>         <steps>
>         =09&login;
>         =09<clicklink stepid=3D"click on I forgot my Password link"
>                                 label=3D"I forgot my Password"
>                                 save=3D"request_new_password_form"/>
>         </steps>
>   </testSpec>
>
> In order to make xml (and thus ant and webtest) aware of that
> entity, you have to define it. This can be done inside your
> test.xml file or in the dtd you refer to. see
> http://webtest.canoo.com/manual/samples.html#Including%20Files
> The selftests that come with webtest show how to use
> entities through dtd definitions. This seems to be a little bit
> easier to manage when the number of modules grows (and modules
> again call other modules,etc.).
>
> cheers
> Mittie
>
> -----Original Message-----
> From: webtest-admin@... [mailto:webtest-admin@...]On
> Behalf Of Marco Neri
> Sent: Montag, 22. November 2004 6:15
> To: 'webtest@...'
> Subject: [Webtest] re: targetB depends on targetA. how to continue sessio=
n
> from one target to another ?
>
> Hi Mittie/Dierk
> I have an ant file login.xml. I want to use this as a re-usable module (
> similar to the example notes modules/login.xml )
> i could get this to work if i copy the examples and declare an entity mod=
ule
> for it. The notes say "As soon as you find yourself using code a second
> time, don't copy but refactor. Put it in a property, an own ant file, a
> separate target, or a module (external entity)."
> How would i set it up to call the ant file from another file and it maint=
ain
> 'state' between the running of 1st target and 2nd. for example.
> <target name=3D"main" depends=3D"login,test"/>
>
>  <target name=3D"login">
>         &definition;
>         <testSpec name=3D"${testid}">
>          <!-- configure target host system -->
>         &config;
>                 <steps>
>           <invoke stepid=3D"login screen"
>                 url=3D"WelcomeForm.aspx"
>                 save=3D"LoginScreen"/>
>               <verifytitle  stepid=3D"verify title"
>                 regex=3D"true"
>                 text=3D"Welcome"/>
>              <verifytext stepid=3D"verify Join Up link on page"
>                 text=3D"Join Up"/>
>          </steps>
>       </testSpec>
>   </target>
>
>   <target name=3D"test">
>   <!--&definition;-->
>         <testSpec name=3D"${testid}">
>         &config; <-- must have this or error says  Required nested elemen=
t
> <config> is not set!
>         <steps>
>         < *** at this point here I need to do an invoke or else i see err=
or
> in the result.xml. i want to be able to continue from
> where login finished.  ***>
>
>         <clicklink stepid=3D"click on I forgot my Password link"
>                                 label=3D"I forgot my Password"
>                                 save=3D"request_new_password_form"/>
>
>         </steps>
>   </testSpec>
>   </target>
> the error is com.canoo.webtest.engine.StepExecutionException: Last respon=
se
> not valid. Is a previous invoke missing?, Step: ClickLink at.
> is there anyway to maintain the state  between the 1st target and the 2nd=
. I
> must include a &Config or i see an error saying &Config not declared.
> what im trying to do is call one ant target and then call the other with
> assumption that the last response is saved so when i try to use click lin=
k
> it is still referencing the login page.
> is there any example of how to do this or the only way is to use entity
> module? each ant target is a discreet build with no way to pass
> state/session to another?
> for example. alluseCasesTestSuite.xml
> <property name=3D"start.page" value=3D"myStartPage"/>
>
> <target name=3D"testSuite">
>         <ant antfile=3D"UseCases/LoginAndStep.xml"/>
>         <ant antfile=3D"UseCases/UseCase2.xml"/>
> </target>
> </project>
>
> how does this work if usecase2.xml has to start off where loginandstep.xm=
l
> finishes?
> danke ( I'm sorry for 2 emails in 1 day!!! )
> Marco
>

On 1/11/06, Mike Danifo <mdanifo@gmail.com> wrote:
> Hello,
> I realize this post is over a year old, but it discusses exactly the prob=
lem I
> am currently facing.
>
> I am trying to implement a similar scenario, trying to implement a reusab=
le
> login module.
>
> The limitation of the solution below is that I'm trying to make the login=
 module
> an ant macro, with an attribute of login.name and login.password, and the=
 below
> solution does not offer a way to call the module and dynamically pass in =
the
> login.name and login.password attributes.
>
> So, instead of using
>
> <!DOCTYPE project SYSTEM "../WebTest.dtd"[
>         <!ENTITY login SYSTEM "login.xml">
> ]>
>
> and calling the entity
>
> &login;
>
> I am trying to do:
>
> <import file=3D"${webtest.script.home}/modules/login.xml"/>
>
> and calling the macro contained in login.xml
>
> <login login.name=3D"webtest" login.password=3D"password"/>
>
> Yet any actions after calling the macro are throwing the error is
> com.canoo.webtest.engine.StepExecutionException: Last response not valid.=
 Is a
> previous invoke missing?
>
> Any ideas for a solution to this problem?
>
> thanks
>
> -Mike
>
>
>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>