应用程序中有多个垂直滚动条时无法滚动

时间:2018-10-19 16:20:32

标签: android automation appium

我的应用程序的屏幕包含两个可滚动元素。我无法选择要滚动到的特定页面。

我已经尝试过了:

逻辑1:

MobileElement element = driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().resourceId(“com.marrow:id/tvIndexTitle”)).getChildByText(”+ “new UiSelector().className(“android.widget.TextView”), “ADVANCED ORTHOPAEDICS & MANAGEMENT”)”));

逻辑2:

MobileElement element = driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().resourceId(“com.marrow:id/tvIndexTitle”)).scrollIntoView(” + “new UiSelector().text(“ADVANCED ORTHOPAEDICS & MANAGEMENT”))”));

我无法执行任何滚动操作。 请为此提供帮助。

1 个答案:

答案 0 :(得分:1)

在两种情况下,您都指定了可滚动视图的相同ID

new UiSelector().resourceId(“com.marrow:id/tvIndexTitle”)

它说明了为什么您要在相同边界

中滚动

建议:

  • 找到第二个可滚动视图的ID,并替换tvIndexTitle或尝试使用索引:new UiSelector().scrollable(true).instance(1)
  • 请勿搜索确切的文本:new UiSelector().text(...),请使用textContainstextStartsWith

示例:

        MobileElement element = driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(UiSelector().scrollable(true).instance(1)).scrollIntoView(new UiSelector().textContains(\"ADVANCED ORTHOPAEDICS\"))";