What is the difference between absolute and relative xpaths? Which is preferred in Selenium automation testing?

前端 未结 3 1598
野趣味
野趣味 2020-12-01 18:51

What is the difference between absolute and relative xpaths? Which is preferred in Selenium automation testing? I am preparing test scripts using Selenium and Robot framewor

3条回答
  •  Happy的楠姐
    2020-12-01 19:19

    Absolute Xpath: It uses Complete path from the Root Element to the desire element.

    Relative Xpath: You can simply start by referencing the element you want and go from there.

    Relative Xpaths are always preferred as they are not the complete paths from the root element. (//html//body). Because in future, if any webelement is added/removed, then the absolute Xpath changes. So Always use Relative Xpaths in your Automation.

    Below are Some Links which you can Refer for more Information on them.

    • difference-between-absolute-path
    • xpath-tutorial-for-selenium
    • choosing-effective-xpath

提交回复
热议问题