向下滚动方法在 Appium 中选择文本
Scroll down method selects text in Appium
我在 Appium 中使用带有坐标的 TouchAction 来向下滚动本机应用程序。代码示例:
TouchAction ts = new TouchAction(driver);ts.press(207, 582).moveTo(8, -360).release().perform();
但有一个警告 - 应用程序中的一个部分包含一大段文字。而不是向下滚动,这些方法选择文本中的单词(就像长按复制单词一样)并且不滚动。
我已经尝试设置坐标以避免在滚动过程中出现文本但无济于事。
import io.appium.java_client.TouchAction;
TouchAction action = new TouchAction(driver);
action.press(PointOption.point(startX,startY))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(500)))
.moveTo(PointOption.point(endX, endY))
.release().perform();
如果您正在自动化 iOS,请查看此内容,
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);
更多详情 - here
我在 Appium 中使用带有坐标的 TouchAction 来向下滚动本机应用程序。代码示例:
TouchAction ts = new TouchAction(driver);ts.press(207, 582).moveTo(8, -360).release().perform();
但有一个警告 - 应用程序中的一个部分包含一大段文字。而不是向下滚动,这些方法选择文本中的单词(就像长按复制单词一样)并且不滚动。 我已经尝试设置坐标以避免在滚动过程中出现文本但无济于事。
import io.appium.java_client.TouchAction;
TouchAction action = new TouchAction(driver);
action.press(PointOption.point(startX,startY))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(500)))
.moveTo(PointOption.point(endX, endY))
.release().perform();
如果您正在自动化 iOS,请查看此内容,
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);
更多详情 - here