Re: [wtr-general] How do I select the second identical table?

2011-08-16 Thread Željko Filipin
On Tue, Aug 16, 2011 at 12:20 AM, Dmitriy Korobskiy dkro...@gmail.com
wrote:
 I'm somewhat stumped trying to select the second table out of multiple
identical tables on the page in Watir 2.0.1. It should be simple, right?

Please note that `:index = 1` in Watir 1.x means the first table, and in
Watir 2.x means the second table.

Please post HTML of the tables.

Željko
--
watir.com - community manager
watir.com/book - author
watirpodcast.com - host

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] How do I select the second identical table?

2011-08-16 Thread Dmitriy Korobskiy

On 8/16/11 4:51 AM, Željko Filipin wrote:
On Tue, Aug 16, 2011 at 12:20 AM, Dmitriy Korobskiy dkro...@gmail.com 
mailto:dkro...@gmail.com wrote:
 I'm somewhat stumped trying to select the second table out of 
multiple identical tables on the page in Watir 2.0.1. It should be 
simple, right?


Please note that `:index = 1` in Watir 1.x means the first table, and 
in Watir 2.x means the second table.

Sure. I'm using 2.0.1 and I need the second table.


Please post HTML of the tables.

Željko

Here is the relevant fragment. The target table is highlighted in bold.

table width=1000 cellpadding=0 cellspacing=0 border=0 
align=center bgcolor=#ff

tr
td align=left valign=top class=content_bgimg 
src=images/point.gif width=1 height=1 border=0/td

td align=left valign=top

!-- InstanceBeginEditable name=Content --

table cellpadding=0 cellspacing=0 border=0 align=center 
width=95%

tr
td colspan=3 align=left valign=topimg src=images/point.gif 
width=1 height=15 border=0 //td

/tr

tr
td colspan=3 align=left valign=top class=headertxtMy Open 
Carts/td

/tr
tr

td colspan=3 align=left valign=topimg src=images/point.gif 
width=1 height=11 border=0 //td

/tr
tr
td colspan=5 align=left valign=middlea 
href=cartAction.cfm?action=newimg src=images/new_cart_bt.gif 
alt=New Cart width=90 height=24 border=0 //a/td

/tr
tr
td align=left valign=top
table class=tablesorter data
cellpadding=5 cellspacing=1 style=width:950px;
thead

tr
th class=smalltxt width=300pxCart Name/th
th class=smalltxt width=150pxCreated Date/th
th class=smalltxt width=150pxLast Updated Date/th
th class=smalltxt width=200pxActions/th
th class=smalltxt width=100pxStatus/th

/tr/thead
tbody

tr
td class=row1a 
href=cartAction.cfm?action=selectcartId=KorobskiyD_110714135613  
class=link1KorobskiyD_110714135613/a/td

td class=row1Jul 14, 2011 1:56 PM/td
td class=row1Jul 29, 2011 11:34 AM/td
td class=row1a 
href=cartAction.cfm?action=submitcartId=KorobskiyD_110714135613 
class=link1img src=./images/submit_icon_n.gif title=Submit Cart 
alt=Submit Cart border=0 hspace=4/a a 
href=deleteConfirmation.cfm?cartId=KorobskiyD_110714135613 
class=link1img src=./images/delete_icon_n.gif title=Delete Cart 
alt=Delete Cart border=0 hspace=4/a a 
href=cartHistory.cfm?cartId=KorobskiyD_110714135613 class=link1img 
src=./images/cart_history_icon.gif title=Cart History alt=Cart 
History border=0 hspace=4/a/td


td class=row1Open/td
/tr

tr
td class=row1a 
href=cartAction.cfm?action=selectcartId=KorobskiyD_110816050326  
class=link1KorobskiyD_110816050326/a/td

td class=row1Aug 16, 2011 5:03 AM/td
td class=row1Aug 16, 2011 5:03 AM/td
td class=row1a 
href=deleteConfirmation.cfm?cartId=KorobskiyD_110816050326 
class=link1img src=./images/delete_icon_n.gif title=Delete Cart 
alt=Delete Cart border=0 hspace=4/a a 
href=cartHistory.cfm?cartId=KorobskiyD_110816050326 class=link1img 
src=./images/cart_history_icon.gif title=Cart History alt=Cart 
History border=0 hspace=4/a/td


td class=row1Open/td
/tr

/tbody
/table
/td
/tr
tr
td colspan=3 align=left valign=topimg src=images/point.gif 
width=1 height=29 border=0 //td


/tr

tr
td colspan=3 align=left valign=top class=headertxtMy Submitted 
Carts/p/td

/tr
tr
td align=left valign=top
*table class=tablesorter data
align=left cellpadding=5 cellspacing=1 
style=width:950px; border=0

theadtr


th class=smalltxt width=300pxCart Name/th
th class=smalltxt width=150pxCreated Date/th
th class=smalltxt width=150pxLast Updated Date/th
th class=smalltxt width=200pxActions/th
th class=smalltxt width=100pxStatus/th
/tr/thead

tbody

tr

td class=row1a href=cart.cfm?cartId=KorobskiyD_110712121510 
class=link1KorobskiyD_110712121510/a/td

td class=row1Jul 12, 2011 12:15 PM/td
td class=row1Jul 14, 2011 1:54 PM/td
td class=row1a 
href=cartHistory.cfm?cartId=KorobskiyD_110712121510 class=link1img 
src=./images/cart_history_icon.gif title=Cart History alt=Cart 
History border=0 hspace=4/a/td

td class=row1Submitted to NBS/td

/tr

tr

td class=row1a href=cart.cfm?cartId=TEST class=link1TEST/a/td
td class=row1Jun 26, 2011 8:57 PM/td
td class=row1Aug 16, 2011 5:01 AM/td
td class=row1a href=cartAction.cfm?action=exportcartId=TEST 
class=link1img border=0 
hspace=4src=./images/download_spread_i.gif title=Download 
Spreadsheet alt=Download Spreadsheet/a a 
href=cartHistory.cfm?cartId=TEST class=link1img 
src=./images/cart_history_icon.gif title=Cart History alt=Cart 
History border=0 hspace=4/a/td

td class=row1Spreadsheet Generated/td

/tr

/tbody
/table*
/td
/tr

/tablebr/br/
!-- InstanceEndEditable --

/td
td align=left valign=top class=content_bgimg 
src=images/point.gif width=1 height=1 border=0/td


/tr
/table

--
DK
AIM: DKroot1, Skype: DKroot

--
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] How do I select the second identical table?

2011-08-15 Thread Dmitriy Korobskiy
I'm somewhat stumped trying to select the second table out of multiple 
identical tables on the page in Watir 2.0.1. It should be simple, right?


In Watir-WebDriver:

carts = @browser.*tables*(:xpath = table_xpath(carts))[1]
# works

carts = @browser.*table*(:xpath = table_xpath(carts), :index = 1)
# works as well

In Watir:

carts = @browser.*tables*(:xpath = table_xpath(carts))
# Watir::Exception::MissingWayOfFindingObjectException: xpath is an 
unknown way of finding a Table element


carts = @browser.*table*(:xpath = table_xpath(carts), :index = 1)
# Selects the first table regardless of the index passed. I have an 
impression that it is ignored because carts = @browser.*table*(:xpath = 
table_xpath(carts), :index = 2) selects the same table.


One solution I could think of so far is to add index into the XPath 
expression itself. Another is to introduce table ids into the source 
application.

Both are somewhat hairy.

--
DK
AIM: DKroot1, Skype: DKroot

--
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com