Testing the text in a comment node using XPathby Group Public on Monday February 22 2010 @ 10:44:32 (1/1 Points) |
|
| Tutorial ↪User Guide ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It |
In many cases you may have a website where important information is stored within comment nodes. This is usually debugging information which is helpful in your automated tests. Working with this information may at first seem tricky in XPath.
comment()
In XPath you can match any comment node using the comment() node test, or you can use the same syntax to select the text of a comment for comparison.
For example, if you wish to get the inside a div which contains a particular comment, you may do this:
set %Value% as response string(//div[contains(comment(),'SomeToken)])
In some cases you may wish to check that some comment exists inside a div. In this case you can explicitly check the value of the comment.
Check //div//comment()[string()='SomeToken']
This checks that there is a div which contains a comment with the exact string value of SomeToken.
TestPlan Testing the text in a comment node using XPath
