'starts-with()' method is used to identify an element when one
is familiar with the attribute value of an element. This method checks
the starting text of an attribute. It is very handy to use when the
attribute value changes on refresh or any operation on the webpage. We
can also use this method to find the element whose attribute value is
static.
For example:
Suppose the ID of particular element changes dynamically like:
- Id="message1"
- Id="message2"
- Id="message3"
Syntax:
//tag[starts-with(@attribute, 'value')]Example:
//input[starts-with(@id, 'user-message')]In the above example, XPath finds those element whose 'ID' starting with 'user-message'.
No comments:
Post a Comment