Javaクライアントを使用してAppiumでAndroidアプリをスクロールすることができません。

MC-SM9:

私はAppiumを使ってAndroidアプリで任意のページの一番下までスクロールすることができません。複数のアプローチは、スタックオーバーフローの上に見られるものを含め、試みられました。(この課題は、一般的なようです。)しかし、すべての試みが失敗しました。

環境:

  • Appiumバージョン1.6.2
  • Appiumクライアント:ジャワ(Javaのクライアント-6.1.0.jar)
  • Androidのバージョン:5.1、6.0.1、7.1.1
  • Javaのバージョン:jre1.8.0_171
  • セレンバージョン:セレンのjava-3.13.0
  • アプリの種類:コルドバ(ハイブリッド)。アプリはコルドバで構築されていますが、実行している場合System.out.println(driver.getContext());、結果はNATIVE_APP

この問題を解決することができます任意の代替または改良を共有してください。任意の有用な提案は大歓迎です!

以下は、試行された様々なアプローチを要約したものです。

  1. アプローチ:のscrollIntoView()(様々な実装形態)
  2. driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(resourceId(\"send-to-email-app\"));").click();
    • 出典:Udemyコース
    • エラー:しないのスクロールとNOエラー

  3. アプローチ:トライキャッチ>のscrollIntoView()
  4. try { driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"Send\"))"); }catch(Exception e) { System.out.println("We got an error scrolling!"); }
    • 出典:https://stackoverflow.com/questions/39658626/how-to-scroll-top-to-botton-using-android-driver
    • エラー:一部動作します:ダウンが、十分ではないページをスクロール

  5. アプローチ:スワイプ
  6. driver.swipe(0, Startpoint,0,scrollEnd,1000);
    • 出典:https://stackoverflow.com/questions/39130591/swipe-or-scroll-to-bottom-in-appium-android
    • エラー:スワイプが廃止されました

  7. アプローチ:touchAction.longPress +のmoveTo
  8. ...touchAction.longPress(fromX, fromY).moveTo(toX, toY).release().perform();
    • 出典:https://stackoverflow.com/questions/44282417/how-to-scroll-with-appium-1-7-1-using-touchaction
    • エラー:「ドライバーは解決できません」

  9. アプローチ:touchAction.longPress +のmoveTo
  10. TouchAction touchAction = new TouchAction(driver); touchAction.longPress(10, 10).moveTo(x, y).release().perform();
    • 出典:https://stackoverflow.com/questions/44282417/how-to-scroll-with-appium-1-7-1-using-touchaction
    • エラー:「メソッドlongPress(LongPressOptions)型TouchActionでは、引数(int型、int型)には適用されません」

  11. アプローチ:touch.longPress +のmoveTo
  12. ...TouchAction touch = new TouchAction(driver); touch.longPress(co_ordinates[0], co_ordinates[1]).moveTo(dinates[0], dinates[1]).release().perform();
    • 出典:https://stackoverflow.com/questions/50304699/how-to-scroll-to-specific-element-inlatest-version-of-appium-using-java
    • エラー:「お持ち帰りは解決できません」

  13. アプローチ:のmoveTo +座標を使用して
  14. actions.press(startX, startY).waitAction(Duration.ofSeconds(2)).moveTo(endX, endY).release().perform();
    • 出典:http://www.automationtestinghub.com/appium-scroll-examples/
    • エラー:「プレス」アクションが推奨されていません!

  15. アプローチ:スワイプ+のmoveToに押しアプローチを使用して
  16. TouchAction().press(el0).moveTo(el1).release();
    • 出典:https://stackoverflow.com/questions/49004686/scroll-text-area-with-terms-and-conditions-on-hybrid-app-with-appium
    • エラー:「メソッドプレス(AndroidElement)はObject型のために定義されていません」

  17. アプローチ:touchAction「タップ」を使用して座標
  18. TouchAction touchAction = new TouchAction(driver); touchAction.tap(PointOption.point(x, y)).perform();
    • 出典:https://discuss.appium.io/t/scrolling-to-element-in-android-app-using-java/17208
    • エラー:なし。それは部分的に動作します:ダウンページをスクロールしなく十分!

  19. アプローチ:UiScrollableは>親スクロール可能なフレームと子要素を指定します
  20. MobileElement doeButton = driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().text(\"Android scrollbar test\")).getChildByText(" + "new UiSelector().className(\"android.widget.TextView\"), \"Doe\")"));
    • 出典:https://stackoverflow.com/a/51003840/9214050
    • エラー:「:このメソッドを呼び出すためにリフレクションを使用して問題UiSelector引数を解析できませんでした」

  21. アプローチ:UiScrollableは>親スクロール可能なフレームと「のscrollIntoView」子要素を指定します
  22. MobileElement sendEmailButton = driver.findElement(MobileBy.AndroidUIAutomator( "new UiScrollable(new UiSelector().resourceId(\"content\")).scrollIntoView(" + "new UiSelector().resourceId(\"add-task-button\"))")); sendEmailButton.click();
    • 出典:https://stackoverflow.com/a/51003840/9214050
    • エラー:しないのスクロールとNOエラー

  23. アプローチ:CSSスタイルを使用して「真」に「偽」からのページ要素のための「スクロール可能な」属性を変更
    • 出典:http://burnignorance.com/html-tips/making-a-smooth-scroll-view-for-android-ios-in-html/
    • エラー:なし、しかし、アプリはページの一番下までスクロールしません。

  24. アプローチ:タッチアクション:「モバイル:スワイプ」、「モバイル:スクロール」(http://appium.io/docs/en/writing-running-appium/touch-actions/)
  25. JavascriptExecutor js = (JavascriptExecutor) driver; HashMap params = new HashMap(); params.put("direction", "up"); js.executeScript("mobile: swipe", params);
    • 出典:https://stackoverflow.com/questions/32387357/i-cant-make-swipe-gesture-work-for-me-in-appium-using-java#
    • エラー:「不明なモバイルコマンド 『スクロール』のみシェル、startLogsBroadcastは、stopLogsBroadcastコマンドがサポートされています。」

  26. アプローチ:HashMapの+ scrollObject.put
  27. JavascriptExecutor js = (JavascriptExecutor) driver; HashMap scrollObject = new HashMap(); scrollObject.put("direction", "down"); js.executeScript("mobile: scroll", scrollObject);
    • 出典:http://appium.io/docs/en/writing-running-appium/touch-actions/
    • エラー:「不明なモバイルコマンド 『スクロール』のみシェル、startLogsBroadcastは、stopLogsBroadcastコマンドがサポートされています。」

  28. アプローチ:(それはコルドバアプリだから)「のWebView」と「ネイティブ」からアプリの内容を調整
  29. appCapabilities.setCapability("autoWebview", "true");
    • 出典:https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md
    • エラー:メインの「スレッドの例外 『』 org.openqa.selenium.WebDriverException:取るのHttpClient、InputStreamをして長い 『のCreateSessionが』が見つかりませんでしたか、それはアクセスできないため、新しいセッションを作成することは不可能です。」
    • エラー:「org.openqa.selenium.WebDriverException:不明なサーバー側のエラーがコマンドの処理中に元のエラーが発生しました:いいえChromedriverはそれがクローム'58 .0.3029' を自動化することができたhttps://github.com/appium/を参照してください。 appium /ブロブ/マスター/ドキュメント/ EN /書き込み-ランニング-appium /ウェブ/詳細chromedriver.md(警告:サーバは任意のスタックトレース情報を提供しませんでした)。」
トースト:

上記提案のオプションのバリエーションとして、ここでは実装のもう一つの方法であるTouchActionとの組み合わせでpressそしてmoveTo私のために働いた方法。これは、下方画面スワイプもたらします。あなたは、単にあなたのクライアントに最高の作品何に座標を調整する必要がある場合があります。

new TouchAction(driver).press(PointOption.point(550, 640)).waitAction().moveTo(PointOption.point(550, 60)).release().perform();

追加情報については、あなたは、これらの参照をチェックアウトすることがあります。

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=179797&siteId=1