I thought this thread from $work would be interesting to this audience. Thomas Milne writes: > Looking through a lot of the selenium tests that are involved > manipulating editTables to select checkboxes, the XPath expressions > which are being used to select individual rows are all positional. > After some discussion with Shawn he's found an awesome way to > identify rows in tables based on contents of the divs inside the > table: heres an example: > > Old: > //[EMAIL PROTECTED]'tbl_hosts']//tr[3]//input > New: > //[EMAIL > PROTECTED]'tbl_hosts']//tr[descendant::div[text()='awesome.example.com']]//input > > I had no idea XPath could do this. If we can modify all our scripts > to refernce entries based on contents rather than absolute positions > our scripts should get a lot more robust and require a whole lot > less in the way of setups & teardowns. I know this is only > scratching the surface but XPath seems pretty powerful.
Shawn McKenzie replies: > Actually, some of this is vestigial. If 'awesome.example.com' is > unique, you could simplify it to: > > //tr[descendant::div[text()='awesome.example.com']]//input If anyone knows of some XPath recipies or cheat-sheets, please pass them on. Cheers, Luke -- Luke Closs PureMessage Developer There is always time to juggle in the Sophos Zone. _______________________________________________ Selenium-users mailing list Selenium-users@lists.public.thoughtworks.org http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users