绝对和相对xpath有什么区别? Selenium自动化测试中首选哪个? [英] What is the difference between absolute and relative xpaths? Which is preferred in Selenium automation testing?
问题描述
绝对路径xpath和相对路径xpath有什么区别? Selenium自动化测试中首选哪个? 我正在使用Selenium和Robot框架准备测试脚本.
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 framework.
推荐答案
绝对Xpath :它使用从根元素到期望元素的完整路径.
Absolute Xpath: It uses Complete path from the Root Element to the desire element.
相对Xpath :您可以简单地从引用所需元素开始,然后从那里开始.
Relative Xpath: You can simply start by referencing the element you want and go from there.
相对Xpath始终是首选,因为它们不是来自根元素的完整路径. (//html//body).因为在将来,如果添加/删除任何Web元素,则绝对Xpath会更改.因此,请始终在自动化中使用相对Xpath.
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
这篇关于绝对和相对xpath有什么区别? Selenium自动化测试中首选哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!