如果元素具有多个id值,如何使用@FindBy查找元素 [英] How to find elements with @FindBy if they have multiple id values

查看:98
本文介绍了如果元素具有多个id值,如何使用@FindBy查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用两个可能的id声明页面元素(带有@FindBy或@AndroidFindBy的移动元素),这些ID会根据正在测试的应用程序的版本而有所不同-我们将拥有一个用于暂存版本的ID另一个用于生产,它们会略有不同(一个将在id值的中间带有"debug",而另一个则不会)

What I need is to declare page elements (mobile elements, with @FindBy or @AndroidFindBy) with two possible ids that will change depending on the version of the app that is being tested - we will have one id for the staging version and one for production and they will slightly different (one will have "debug" in the middle of the id value, and the other won't)

这可能吗(通过使用OR或任何其他方式)以及如何?

Is this possible (by using OR or any other way) and how?

谢谢.

推荐答案

您可以使用注释 @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.

这篇关于如果元素具有多个id值,如何使用@FindBy查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆