我有一个包含大约 50 个元素的 UITableView。在任何时候,屏幕上都只能看到其中的 6 个。我想选择一个未添加到 TableView 的单元格,或者说我需要从数据列表中选择第 25 项。
现在我正在使用这种方法在tableview中点击一个单元格
wait.until(ExpectedConditions.visibilityOf(driver.findElementByAccessibilityId(element))).click();
但它不起作用,因为第 25 个元素尚未添加到 View 中。请注意,我在代码中动态添加了表格 View 单元格的可访问性标识符。
我怎样才能让它工作?
***** 添加了更多详细信息******
我有显示两个 TextView 的 TableView 单元格。货币短名称和货币长名称。
Consider the example
GBP
Great Britain Pounds
Now the accessibility Identifier for that tableview cell is set as GBP. Now I tried
driver.scrollTo("GBP") and driver.scrollTo("Great Britain Pounds")
两者均无效。我收到一条错误消息
A element could not be located on the page using the Search parameter
谢谢。
最佳答案
String ReqN = "Your required string";
boolean flag = true;
while (flag) {
for (i=1;i<=6;i++) {
String GetN = driver.findElement(By.xpath("//android.widget.HorizontalScrollView/android.widget.LinearLayout[" + i + "]")).getText();
if (GetN.equals(ReqN)) {
flag = false;
System.out.println("Your result found");
}
}
if (flag) {
driver.swipe(145, 765, 145, 180, 3000);
}
}
String ReqN::您预定义的字符串
String GetN::为每个元素获取文本 [我们通过 for 循环获取的 1 到 6]
因此,如果未找到预定义文本,它会获取文本并匹配前六个元素,然后它会从给定轴滑动 [这是第 6 个元素到第一个元素] ..因此您将获得新的六个元素并再次执行循环。
引用。图片 Elements & X,Y points
关于ios - 使用 appium 自动化 IOS UITableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36496139/