On Aug 17, 11:54 am, Dmitriy Korobskiy <[email protected]> wrote:

> Yep, it works to locate the first table, but the second one is the problem.
> I primarily use XPath locators to locate data tables based on columns
> (table headers) that they have.
> I can switch to :class locator actually in conjunction with :index => 1.
> Another option is to to add ids into the source app and switch to id
> locators.

> DK
> AIM: DKroot1, Skype: DKroot

 If you know the specific text in a cell of a table, then you have a
number of options to locate the table.

You can locate via :text and use a regular expression that includes
the text you are looking for

  browser.table(:text, /headerseries/)

You can locate the specific cell or header via :text and use
the .parent method to find the table row, and then table
(.parent.parent) that holds the cell

  browser.th(:text, 'knownheader').parent.parent

If the text is not unique you can combine :text with :index
(something you can't do with xpath)

BTW the same tactic can be used when you have a table where you need
to click a control in a given column in a row that you locate via the
contents of another column..
 E.g. if the first column is a list of names, and the third column
holds a link to perform some action, you know one of the rows (but not
which one) holds the name you are looking for, and you want to click
the link on that row.

   browser.cell(:text, 'targetname').parent.cell(:index, 2).click   #
for watir 1.x index value would be 3

and you don't have to resort to xpath.

-- 
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]

Reply via email to