亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 appium-android 中向上/向下滾動

如何在 appium-android 中向上/向下滾動

不負相思意 2023-06-08 20:39:56
我有一個應用程序頁面,我需要在其中垂直滾動才能到達應用程序的元素。我用谷歌搜索并嘗試了很多解決方案。許多命令已被棄用,并且在 appium 中不再支持。此外,Stack 中以前的問題/答案對我沒有幫助。我正在使用 appium v1.13.0 + Java (IntelliJ)。有時我會看到這個錯誤:java.lang.ClassCastException: io.appium.java_client.android.AndroidDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen無論如何,我的問題不僅僅是解決提到的錯誤。我正在尋找可行且正確的命令來使用 appium 進行滾動操作。請給我完整的示例項目,因為我是初中生。謝謝
查看完整描述

3 回答

?
12345678_0001

TA貢獻1802條經驗 獲得超5個贊

我的刷卡方法:


public void swipe(int startX, int startY, int endX, int endY, int msDuration) {

    TouchAction touchAction = new TouchAction(mDriver);

    touchAction.press(PointOption.point(startX, startY))

            .waitAction(WaitOptions.waitOptions(Duration.ofMillis(msDuration)))

            .moveTo(PointOption.point(endX, endY))

            .release();


    touchAction.perform();

}


查看完整回答
反對 回復 2023-06-08
?
慕森王

TA貢獻1777條經驗 獲得超3個贊

嘗試這個


String scrollViewContainer_finder = "new UiSelector().resourceIdMatches(\".*id/your_scroll_view_id\")";

String neededElement_finder = "new UiSelector().resourceIdMatches(\".*id/elemnt1\")";


WebElement abc = driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(" + scrollViewContainer_finder + ")" +

                ".scrollIntoView(" + neededElement_finder + ")"));


查看完整回答
反對 回復 2023-06-08
?
慕勒3428872

TA貢獻1848條經驗 獲得超6個贊

對于垂直/水平滑動,我使用的是 TouchAction:

TouchAction touchAction = new TouchAction((PerformsTouchActions) driver);
touchAction.press(startPoint)
           .waitAction(WaitOptions.waitOptions(Duration.ofMillis(waitBetweenSwipes)))
           .moveTo(endPoint)
           .release()
           .perform();


查看完整回答
反對 回復 2023-06-08
  • 3 回答
  • 0 關注
  • 299 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號