The following information uses browser test tools for examples, but the same concepts also apply to creating custom XPaths in the XML tools as well (XML Assertor, Data Bank, etc.and so on).
SOAtest generates element locators for use in browser tests; these locators allow SOAtest to find the appropriate element during playback so that SOAtest can, for example, perform a user action on that element or validate an attribute of that element. SOAtest tries to create a locator that will still work after trivial changes to the web page. However, sometimes you will need to create a custom element locator. SOAtest may not have enough information to generate a robust locator.
...
To create custom XPath expressions, you will need to examine the HTML for the given page. Consider a page with the following table.:
Code Block |
---|
<table border="1"> <thead> <th>number</th> <th>comment</th> <th>details link</th> <th>other link</th> </thead> <tbody id="content"> <tr> <td>000</td> <td>nothing special</td> <td><a href="#" id="details000" onclick="foo()">Details</a></td> <td><a href="#">Other</a></td> </tr> <tr> <td>123</td> <td>nothing special</td> <td><a href="#" id="details123" onclick="foo()">Details</a></td> <td><a href="#">Other</a></td> </tr> <tr> <td><em>456</em></td> <td>formatting: nodes within column</td> <td><a href="#" id="details456" onclick="foo()">Details</a></td> <td><a href="#">Other</a></td> </tr> <tr> <td> 789 + 1 </td> <td>whitespace</td> <td><a href="#" id="details789" onclick="foo()">Details</a></td> <td><a href="#">Other</a></td> </tr> <tr> <td>888</td> <td>find my comment</td> <td><a href="#" id="details888" onclick="foo()">Details</a></td> <td><a href="#">Other</a></td> </tr> <tr> <td>999</td> <td>last row</td> <td><a href="#" id="details999" onclick="foo()">Details</a></td> <td><a href="#">Other</a></td> </tr> </tbody> </table> |
...