Wednesday, August 13, 2008

Locate the element inside table row based on text inside row's cell

This is one of the powerfull XPATH query I have seen

selenium.Check("//tr[.//p[contains(text(),'AT Test User 1')]]//input[contains(@name,'members_new')]");

here //tr[.//p[contains(text(),'AT Test User 1')]] returns the table row which has p tag containing text AT Test User 1. Notice the . used here, which refers to the context node
And once that row is selected //input[contains(@name,'members_new')] locates the input element contained in that row.

No comments: