1

我喜欢在我的自动化框架中使用带有 FindBy 注释的 PageFactory 来自动定位我的页面对象类中的元素。

我有一个 WebElement,我需要为其指定几个不同的定位器。我认为 FindBys 是我的解决方案,但显然它不是这样工作的。它相当于 driver.findElement(option1).findelement.(option2)。那不是我需要的。我需要一些可以通过一个或其他定位器找到元素的东西。如果一个不起作用,则使用另一个定位器。有没有办法在 Selenium 中使用 FindBy 注释来做到这一点?

4

1 回答 1

7

截至今年 5 月,Selenium 中显然有一个新功能——@FindAll 注释可以满足我的需要;

http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/support/FindAll.html http://selenium.10932.n7.nabble.com/Pull-Request-62-Add -a-FindAll-annotation-to-the-Java-Page-Factory-td24814.html

于 2013-10-03T18:00:34.223 回答