Even more simple
browser.table(class: 'rctable').td(index: -1).click
On Thursday, May 16, 2013 4:19:35 AM UTC+7, Chuck van der Linden wrote:
>
>
>
> On Thursday, May 9, 2013 6:23:38 PM UTC-7, Ankita@Adslot wrote:
>>
>> If the number of rows is static, would make sense to use xpath and locate
>> the last row with it and then click on image of the last row.
>>
>> something like
>>
>> b.element(:xpath,"//table[@class='rctable']/tbody/tr[15]/td[2]/img[@src='
>> /tracker/images/skin2/bolean.png']").click
>>
>
> If the number of rows/cells is predictable you don't need to resort to
> xpath, just do something like
>
> browser.table(:class => "rctable")[15][2].img.click
>
> A few other things that might work
>
> browser.table(:class => 'rctable').rows.last.img.click
>
>
>>
>> On Wednesday, May 1, 2013 12:44:18 AM UTC+10, watir webdriver wrote:
>>>
>>> Sorry Filipin...ignore my previous comment...its not working and still
>>> its clicking on the first <td> in the table.
>>>
>>> Any one can help me in this ?
>>>
>>> On Thursday, April 25, 2013 5:34:21 PM UTC+1, watir webdriver wrote:
>>>>
>>>> Hi there,
>>>>
>>>> In my application,I've to select the last td (which is an img) in
>>>> table.Can anyone help me with this ?
>>>>
>>>> *HTML :*
>>>>
>>>> <table class="rctable">
>>>> <thead>
>>>> <tbody>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=6">Shirts main</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=6">
>>>> <a href="edit.page?id=6">
>>>> <a href="?duplicateId=6">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=7">Suits main</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=7">
>>>> <a href="edit.page?id=7">
>>>> <a href="?duplicateId=7">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=8">Shoes main</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=8">
>>>> <a href="edit.page?id=8">
>>>> <a href="?duplicateId=8">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=10">Womens main</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=10">
>>>> <a href="edit.page?id=10">
>>>> <a href="?duplicateId=10">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=11">Coats side</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=11">
>>>> <a href="edit.page?id=11">
>>>> <a href="?duplicateId=11">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=12">Knitwear side</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=12">
>>>> <a href="edit.page?id=12">
>>>> <a href="?duplicateId=12">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=13">New side</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=13">
>>>> <a href="edit.page?id=13">
>>>> <a href="?duplicateId=13">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=14">Shoes side</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=14">
>>>> <a href="edit.page?id=14">
>>>> <a href="?duplicateId=14">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=15">Ties side</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=15">
>>>> <a href="edit.page?id=15">
>>>> <a href="?duplicateId=15">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=16">Womens side</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=16">
>>>> <a href="edit.page?id=16">
>>>> <a href="?duplicateId=16">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=19">Home page spring</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=19">
>>>> <a href="edit.page?id=19">
>>>> <a href="?duplicateId=19">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=34">fhg</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=34">
>>>> <a href="edit.page?id=34">
>>>> <a href="?duplicateId=34">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=36">AutoTestCreative</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=36">
>>>> <a href="edit.page?id=36">
>>>> <a href="?duplicateId=36">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=37">AutoTestCreative</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=37">
>>>> <a href="edit.page?id=37">
>>>> <a href="?duplicateId=37">
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td>
>>>> <a href="edit.page?id=38">AutoTestCreative</a>
>>>> </td>
>>>> <td>
>>>> <a onclick="return confirm('Delete creative?')"
>>>> href="delete.page?cid=38">
>>>> <a href="edit.page?id=38">
>>>> <a href="?duplicateId=38">
>>>> *<img title="Duplicate" src="/tracker/images/skin2/bolean.png">*
>>>> </a>
>>>> </td>
>>>> </tr>
>>>> </tbody>
>>>> </table>
>>>>
>>>> Implemenetd as below :
>>>>
>>>> @browser.img(:src => "/tracker/images/skin2/bolean.png").click
>>>>
>>>> which is clicking on the first image.
>>>>
>>>> Help is much more appreciated.
>>>>
>>>> Thanks.
>>>>
>>>
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.