且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果元素具有多个id值,如何使用@FindBy查找元素

更新时间:2021-12-08 10:25:17

您可以使用注释 @FindAll .这是示例:

You can use the annotation @FindAll. Here is the example:

@FindAll({
        @FindBy(id = "one_id"),
        @FindBy(id = "another_id")
})
WebElement myElement;

请参见 docs .

这种方法的优点是您实际上可以组合不同类型的定位器.

The advantage of this approach is that you can actually combine the locators of different types.