【发布时间】:2017-12-30 14:25:13
【问题描述】:
我有一个列表视图,它具有我理论上不知道的层次结构。我试图接受一个字符串数组并为其中的每个字符串创建 MobileElements,但是由于我通过注释自动定义我的元素的方式(PageFactory),它们不能使用变量。我也不知道在方法中定义我的注释是否有效或正确。
我写的代码,显然不能编译如下:
public void selectLocation(String[] location) {
List<MobileElement> locationsList = new ArrayList<>();
for(int i = 0; i < location.length; i++) {
@iOSFindBy(accessibility = location[i])
@AndroidFindBy(xpath = "//android.widget.TextView[@text='" + location[i] + "']")
locationsList.add(i);
}
for (int i = 0; i < location.length; i++) {
locationsList.get(i).click();
}
}
我假设执行此操作的正确方法与我实施的方法完全不同。
我的列表层次结构类似于以下内容;我的终点可能会因我走的分支而异:
- 大陆 1
- 城市 1
- 1号房间
- 2号房间
- 城市2
- 1号楼
- 1号房间
- 2号房间
- 2号楼
- 1号房间
- 2号房间
- 1号楼
- 城市 1
【问题讨论】:
标签: java appium appium-ios