硒4中的相对定位符是什么?它的类型是什么?

时间:2019-10-05 14:04:25

标签: selenium automation ui-automation

我最近听说了 Selenium 4 中的相对定位符。那么它到底是什么?它的类型是什么?

其次,这将如何帮助查找与当前定位符不同的元素,例如(id,name,tagname,classname,cssselector,xpath,linktext,partiallinktext)。

3 个答案:

答案 0 :(得分:3)

我写了一篇博客文章,解释了新方法,它们如何工作以及陷阱。 http://angiejones.tech/selenium-4-relative-locators/

答案 1 :(得分:2)

这是一种根据元素相对于其他元素的位置查找元素的新方法(在...上方,下方,右侧)。 这是硒文档的链接: https://github.com/SeleniumHQ/selenium/blob/master/java/client/test/org/openqa/selenium/support/locators/RelativeLocatorTest.java

答案 2 :(得分:2)

主定位器是 tagName ,上面有不同的方法 toLeftOf,下方,上方,toRightOf

要实现此硒,请使用getBoundingClientRect()Java脚本函数。