Xpath has absolute paths and relative paths,

Absolute path: start with THE HTML and work your way up to the relative path of the target element: start with a well-positioned element, use that element as the base position, and then use the path method to find the target element

Xpath syntax structure

//*[@id=”kw”] // indicates that the search starts from the path * indicates that any element [] the parentheses indicate the filter criteria @ indicates that the search is based on attributes e.g. @id=”kw” indicates that the search is based on the element whose id attribute is kw

Verify that the Xpath path is correct

1. From the Google Developer tools, Element page, use CMD + F to open the search bar, which supports xpath syntax 2. The element can also be located via the concle interface using $(‘xpath’) + Enter

$x('//input[@id="kw"]') {input# kw.ipt}Copy the code

Xpath localization method

1. A Label contains text

//*[@id=”kw”] @id=” id “; //*[@id=”kw”] @id=” id “;

3. When looking for a dynamic element, reverse the path to the target element by the static element of the parent element or the child element note /.. You can find the parent of the relative element