how to identify the same value buttons

0 views
Skip to first unread message

William

unread,
Mar 10, 2008, 4:15:02 AM3/10/08
to Watir General
There are some "Delete" buttons on my test page,using Watir to click
but i don't know how to identify these same value buttons.The delete
button syntax as below:
<input class='ButtonText' type='button' value='Delete'
onclick='doDeleteOne(3,"4140");'>

What can I do if meet this?

Aakash Pradeep

unread,
Mar 10, 2008, 4:18:36 AM3/10/08
to watir-...@googlegroups.com
Hi,
U can use the index...like

$ie.button(:index,1).click

Regards,
Aakash

William

unread,
Mar 10, 2008, 5:04:39 AM3/10/08
to Watir General
Thanks,it works with index method.
But should i try better way?such as Xpath,can you give me some help
about this?
> What can I do if meet this?- Hide quoted text -
>
> - Show quoted text -

Aakash Pradeep

unread,
Mar 10, 2008, 5:09:00 AM3/10/08
to watir-...@googlegroups.com
But I don't think it will help u better .... as it also depends on the attribute to identify element uniquely and it use to return whichever element it finds first with the given path.. but here u c both has the same xpath...so it always return the first one only.....
Index works because it enumerate the elements... so u can find the second button element....that wat means here from
$ie.button(:index,2)
I hope u get wat I m trying to convey u....

Željko Filipin

unread,
Mar 10, 2008, 6:53:15 AM3/10/08
to watir-...@googlegroups.com
On Mon, Mar 10, 2008 at 9:15 AM, William <sz...@grandstream.com> wrote:
> <input class='ButtonText' type='button' value='Delete'
> onclick='doDeleteOne(3,"4140");'>

If you know that the button's onclick attribute will contain 4140 you could try this:

ie.button(:xpath, "//input[contains(@onclick , '4140')]").click

Željko
--
ZeljkoFilipin.com
Reply all
Reply to author
Forward
0 new messages