Explain XPath Absolute and XPath Attributes.

XPath Absolute:

  • XPath Absolute enables users to mention the complete XPath location from the root HTML tag to the specific elements.
  • Syntax: //html/body/tag1[index]/tag2[index]/…/tagN[index]
  • Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]
    XPath Attributes:
  • XPath Attributes is always recommended when you don’t have a suitable id or name attribute for the element you want to locate.
  • Syntax: //htmltag[@attribute1=’value1′ and @attribute2=’value2′]
  • Example: //input[@id=’passwd’ and @placeholder=’password’]