Friday, October 12, 2018

Generating XPath With Single Attribute

Single attribute XPath uses one attribute to locate an web element.

Syntax:
//tag[@attribute = 'value']
Example:
//input[@id = 'user-message']
This would select the input element nodes which has 'user-message' as it’s id attribute value.

Let's get a clear view with the below example:
//li[@id = 'ogbkddg:4']
How do I extract an attribute's value through XPath?

Here, //li[@id = 'ogbkddg:4'] selects all the 'li' node which has 'ogbkddg:4' as it's attribute id.

No comments:

Post a Comment