[Webtest] Undesired behaviour after canceling a confirm dialog

Kai Mütz Kai Mütz
Wed, 23 Jul 2008 12:12:25 +0200


Hi,

I am new to webtest thus I am not sure if this problem is due to my
ignorance. There is a simple link with confrirmation on click event:

<a href="{removeItem?id=123456" onclick="return confirm('Are you sure you
want to remove this document?');">
<img src="images/clear.gif" alt="Remove item" border="0"/>
</a>

I am testing the cancel button like this:

<expectDialog dialogType="confirm" response="false"
saveProperty="confirmItemRemoval" />
<clickLink xpath="//td[a/text() = '${item}']/following-sibling::td[5]/a"/>
<verifyProperty name="confirmItemRemoval" text="Are you sure you want to
remove this document?"/>
<verifyNoDialogs description="Check all dialogs were used" />
<verifyText text="${item}"/>

The problem is that the link will be invoked and the item removed though the
confirmation is canceld.

The log file says:

2008-07-23 11:44:08,096 INFO  com.canoo.webtest.steps.Step: >>>> Start Step:
clickLink (7/10)
2008-07-23 11:44:08,096 DEBUG
com.canoo.webtest.steps.request.AbstractIdOrLabelTarget: Looking for html
element with xpath: //td[a/text() = 'Test Item']/following-sibling::td[5]/a
2008-07-23 11:44:08,096 DEBUG
com.canoo.webtest.steps.request.AbstractIdOrLabelTarget: XPath evaluates to:
HtmlAnchor[<a onclick="return confirm(&apos;Are you sure you want to remove
this document?&apos;);" href="/removeItem?id=1216803945367">]
2008-07-23 11:44:08,096 DEBUG com.canoo.webtest.steps.request.ClickLink:
Clicking on link with href: /removeItem?id=1216803945367
2008-07-23 11:44:08,637 INFO  com.canoo.webtest.engine.WebClientContext:
Content of window changed to http://localhost:8080/folder/global (text/html)
2008-07-23 11:44:08,637 INFO  com.canoo.webtest.engine.WebClientContext:
Content of current window changed, it will become current response
2008-07-23 11:44:08,637 INFO  com.canoo.webtest.engine.WebClientContext:
Current form set to none
2008-07-23 11:44:08,637 INFO  com.canoo.webtest.engine.WebClientContext:
Current response now: http://localhost:8080/folder/global
2008-07-23 11:44:08,647 INFO  com.canoo.webtest.steps.Step: >>>> Start Step:
verifyProperty (8/10)
2008-07-23 11:44:08,657 INFO  com.canoo.webtest.steps.Step: >>>> Start Step:
verifyNoDialogs "Check all dialogs were used" (9/10)
2008-07-23 11:44:08,657 INFO  com.canoo.webtest.steps.Step: >>>> Start Step:
verifyText (10/10)

Steo 10 fails with:
Step[verifyText (10/10)]: Text not found in page. Expected <Test Item>


Am I doing something wrong or is this a bug? In other similar situations
this works.

Regrads, kai