1 message in com.canoo.lists.webtest[Webtest] click button on form
FromSent OnAttachments
Jérome Macias25 Aug 2004 03:21 
Subject:[Webtest] click button on form
From:Jérome Macias (Jero@netonomy.com)
Date:08/25/2004 03:21:36 AM
List:com.canoo.lists.webtest

Hi,

I have the following issues when running web test scripts against that attached
HTML pages which are quite simple

My HTML page contains 12 forms with in each a submit button

They are 6 forms with name monthly and 6 form with name payAsYouGo

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" >

<title>the Wireless Online shop - Choose your handset</title>

</head>

<body>

<form name="monthly" method="get" action="BrandTwoHB.htm">

<input type="submit" name="monthly" value="Pay monthly">

</form>

<form name="payAsYouGo" method="get" action="BrandTwoHB.htm">

<input type="submit" name="payAsYouGo" value="Pay as you go">

</form>

<br/>

<form name="monthly" method="get" action="BrandOneHA.htm">

<input type="submit" name="monthly" value="Pay monthly">

</form>

<form name="payAsYouGo" method="get" action="BrandOneHA.htm">

<input type="submit" name="payAsYouGo" value="Pay as you go">

</form>

<br/>

<form name="monthly" method="get" action="TheBrandNow.htm">

<input type="submit" name="monthly" value="Pay monthly">

</form>

<form name="payAsYouGo" method="get" action="TheBrandNow.htm">

<input type="submit" name="payAsYouGo" value="Pay as you go">

</form>

<br/>

<form name="monthly" method="get" action="BrandOneH0.htm">

<input type="submit" name="monthly" value="Pay monthly">

</form>

<form name="payAsYouGo" method="get" action="BrandOneH0.htm">

<input type="submit" name="payAsYouGo" value="Pay as you go">

</form>

<br/>

<form name="monthly" method="get" action="BrandOneH1.htm">

<input type="submit" name="monthly" value="Pay monthly">

</form>

<form name="payAsYouGo" method="get" action="BrandOneH1.htm">

<input type="submit" name="payAsYouGo" value="Pay as you go">

</form>

<br/>

<form name="monthly" method="get" action="BrandOneH2.htm">

<input type="submit" name="monthly" value="Pay monthly">

</form>

<form name="payAsYouGo" method="get" action="BrandOneH2.htm">

<input type="submit" name="payAsYouGo" value="Pay as you go">

</form>

</body>

</html>

I need to write some tests step to click on the First button then on the third
button then on the last button

For this I am using the click button step with form and index attributes

<steps>

<!- case 1 -->

<invoke stepid="get home page" url="/ChooseYourHandset.htm" />

<clickbutton stepid="Submit Pay as you go button on first handset (BrandTwo HB)"
name="payAsYouGo">

<form name="PayAsYouGo" />

<index value="0"/>

</clickbutton>

<verifytext stepid="Verify is the first Handset (BrandTwo HB) ac 'index value=0
and form name=PayAsYouGo'" text="BrandTwo HB"/>

<!- case 2-->

<invoke stepid="get home page" url="/ChooseYourHandset.htm" />

<clickbutton stepid="Submit Pay as you go button on first handset (BrandTwo HB)"
name="payAsYouGo">

<index value="0" />

</clickbutton>

<verifytext stepid="Get the last Handset (BrandOne H2) instead of the first
handset which is not correct for us" text="BrandOne H2"/>

<!- case 3 -->

<invoke stepid="get home page" url="/ChooseYourHandset.htm" />

<clickbutton stepid="Submit Pay as you go button on first handset (BrandTwo HB)"
name="payAsYouGo">

<index value="2"/>

</clickbutton>

<verifytext stepid="Get the last Handset (BrandOne H2) instead of the third
handset which is not correct for us!" text="BrandOne H2"/>

<!- case 4 -->

<invoke stepid="get home page" url="/ChooseYourHandset.htm" />

<clickbutton stepid="Submit Pay as you go button on first handset (BrandTwo HB)"
name="payAsYouGo">

<index value="5"/>

</clickbutton>

<verifytext stepid="Get the last Handset (BrandOne H2) it is correct for us!"
text="BrandOne H2"/>

<!- case 5 -->

<invoke stepid="get home page" url="/ChooseYourHandset.htm" />

<clickbutton stepid="Submit Pay as you go button on first handset (BrandTwo HB)"
name="payAsYouGo">

<form name="PayAsYouGo" />

<index value="2" />

</clickbutton>

<verifytext stepid="It's the last Handset (BrandOne H2) ac 'index value=2 and
form name=PayAsYouGo'" text="BrandOne H2" />

</steps>

The click button in case 1 and 4 gives me the expected page

The click button in case 2 and 3 gives me the page corresponding to the last
button

The click button in case 5 generates the following exception

[testSpec] ERROR (Step.java:340) - Cannot handle unexpected exception in step
ClickButton at
E:\P4\depot\apps\swf\eshop\smoketests\testcases\BugOfIndexValueNumber.xml:45:
with (stepId="Submit Pay as you go button on fi

rst handset (BrandTwo HB)", name="payAsYouGo", stepType="clickbutton")

[testSpec] java.lang.IndexOutOfBoundsException: Index: 2, Size: 1

[testSpec] at java.util.ArrayList.RangeCheck(ArrayList.java:507)

[testSpec] at java.util.ArrayList.get(ArrayList.java:324)

[testSpec] at
com.canoo.webtest.steps.locator.IndexLocator.locateItem(IndexLocator.java:23)

[testSpec] at
com.canoo.webtest.steps.locator.ButtonLocator.locateButtonByIndex(ButtonLocator.java:107)

[testSpec] at
com.canoo.webtest.steps.locator.ButtonLocator.locateButtonByFormLocator(ButtonLocator.java:88)

[testSpec] at
com.canoo.webtest.steps.locator.ButtonLocator.locateButton(ButtonLocator.java:47)

[testSpec] at
com.canoo.webtest.steps.request.ClickButton.doExecute(ClickButton.java:138)

[testSpec] at com.canoo.webtest.steps.Step.execute(Step.java:104)

[testSpec] at com.canoo.webtest.engine.Engine.executeSteps(Engine.java:26)

[testSpec] at
com.canoo.webtest.ant.TestSpecificationTask.execute(TestSpecificationTaskjava:70)

[testSpec] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)

[testSpec] at org.apache.tools.ant.Task.perform(Task.java:364)

[testSpec] at org.apache.tools.ant.Target.execute(Target.java:301)

[testSpec] at org.apache.tools.ant.Target.performTasks(Target.java:328)

[testSpec] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)

[testSpec] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)

[testSpec] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)

[testSpec] at org.apache.tools.ant.Task.perform(Task.java:364)

[testSpec] at org.apache.tools.ant.Target.execute(Target.java:301)

[testSpec] at org.apache.tools.ant.Target.performTasks(Target.java:328)

[testSpec] at org.apache.tools.ant.Project.executeTarget(Project.java:1215)

[testSpec] at org.apache.tools.ant.Project.executeTargets(Project.java:1063)

[testSpec] at org.apache.tools.ant.Main.runBuild(Main.java:632)

[testSpec] at org.apache.tools.ant.Main.startAnt(Main.java:183)

[testSpec] at org.apache.tools.ant.Main.start(Main.java:147)

[testSpec] at org.apache.tools.ant.Main.main(Main.java:230)

any helps welcome

Jerome