首页 > 解决方案 > 如何使用android驱动程序在selenium中执行向下滚动操作(直到一定限制,而不是元素可见性)

问题描述

driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()
    .scrollable(true).instance(0))
    .scrollIntoView(new UiSelector()
    .textContains(\""+text+"\").instance(0))");

此语法适用于元素可见性。我需要一种可以向下滚动到特定维度的语法。

标签: androidseleniumscrollappiumdriver

解决方案


您可以使用以下代码滚动购买,只需为您提供从 (x,y) 到位置 (x,y) 的坐标

  new TouchAction(driver).press(PointOption.point(449,1830)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).moveTo(PointOption.point(449, 333)).release().perform();

推荐阅读