[Webtest] problem with onclick link
Costin
webtest@lists.canoo.com
Thu, 18 Nov 2004 23:16:35 +0200
Hello.
I've started using Canoo for our project. I was very impressed with
it's features, especially xml and xpath.
However, JavaScript proved to be a total show stopper. I have for a
more then a day to push a javascript link to be pressed without
success.
Here is my page:
(sample.html)
----
<table width="100%" border="0" cellpadding="0" cellspacing="5" class="tbl">
<tr>
<th scope="col">Name</th>
<th scope="col">Location</th>
<th scope="col">S.W.I.F.T</th>
<th scope="col"></th>
</tr>
<tr >
<td>BRD</td>
<td>Calea Victoriei 224</td>
<td>BRDEROBU</td>
<td>
<a href="editBank.action?bank.bankId=1" ><img
src="/tr/gfx/btn_change.gif" width="35" height="15"/></a>
<a href="#" onclick="if (confirm('Delete ?'))
window.location.href='deleteBank.action?bank.bankId=1'; return false"
htmlid="0"><img src="/tr/gfx/btn_delete.gif" width="50"
height="15"/></a>
</td>
</tr>
</table>
----
this is a table with only one entry. What I'm interested in, is
getting the delete button clicked:
<a href="#" onclick="if (confirm('Delete ?'))
window.location.href='deleteBank.action?bank.bankId=1'; return false"
htmlid="0"><img src="/tr/gfx/btn_delete.gif" width="50"
height="15"/></a>
The xpath computed for this expression is:
//tr/td[text()='BRD']/../td[4]/a[2]/@htmlid
(which should work on any table without duplicated).
The problem is that clicklink simply doesn't work because href is
null, while onclick is totally ignored.
How can I activate the link? I was expected the onclick to be
activated somehow by the clicklink.
My test is already overloaded with xpath expressions; I have tried to
get the window.location.href out of "onclick" attribute but failed to
do so (we are planning in using only XML / XPATH configurations
because we have ppl specialized in this and not in Java).
Pls, take in account that this is an entry from a dynamic table and
the position can change very quickly.
Thanks a lot.
Costin