> And finally, the embedded table:
>
> "//div/span[2]/div/table/tbody/tr/td[3]/table/tbody/tr[3]/td[2]"
> Not sure how CSS would handle embedded tables.
That's a good point, but at least you can define the CSS like this:
"div > span:nth-child(2) > div > table > tbody > tr > td:nth-child(3)
> table > tbody > tr:nth-child(3) > td:nth-child(2)"
If nth-child() doesn't work, give nth-of-type() a try. The CSS can be
tested in Firefix w/ tool like FirePath or Firefinder to see if it can
detect. If works, then it should likely work in Selenium too.
>> If you have multiple tables including tables within tables, this
is more complicated.
Under this circumstance, one other option that can work, if you know
relatively, what order/position the table of interest is, you can
specify it in XPath, w/o needing IDs or specifying the absolute (or
near absolute) XPath. This can be tested out in FirePath, Firefinder,
etc. to figure out what position the table is relative to the DOM.
Though this does assume the table position infrequently changes. If
it's based on custom web design, it might change often, but if the
table was generated with web libraries like dojo, etc., it's less
likely to deviate in changes.
example XPath string:
(//table/tbody/tr[3]/td[2])[3]
returns the 3rd node/element that matches the given XPath in
parenthesis. Replace 3 with number n to get nth element of given
XPath.
On Dec 15, 10:43 am, Bill Ross <
r...@cgl.ucsf.EDU> wrote: