2016-07-06 6 views
3

私は、Javaとappiumを使用してAndroid/iOS用のモバイルアプリケーション自動化テストケースを作成しています。javaクライアントv4.0のscrollToとscrollToExactの置換

私はappiumのバージョンを3.1.0から4.0.0にアップグレードしました。今、私は可能な利用scrollTo()とscrollToExactを()ないです

のJavaクライアントReadMe Readmeには、次の言葉: - scrollTo()scrollToExact()が廃止されました。彼らは次のリリースで削除される予定です。

スワイプ方法以外avaialble他の任意の他の方法と

((MobileElement)element).swipe(SwipeDirection.UP,100); 

のような誰もが scrollToscrollToExactを交換するためのあらゆる可能な方法を知っていますか?

答えて

0

このメソッドは一貫性がなく、削除される予定であるため、非推奨です。実際には回避策です。

AppiumDriver.swipe(int, int, int, int, int) 
MobileElement.swipe(SwipeElementDirection, int) 
MobileElement.swipe(SwipeElementDirection, int, int, int) 

または

により指定
MobileBy.ByAndroidUIAutomator 

使用して要素を検索:

scrollTo in interface ScrollsTo<org.openqa.selenium.WebElement> 

パラメータ: - の説明やテキスト
テキストを代わりに使用することをお勧め

ユーザーに今インターフェースからコピーされswipe

public abstract void swipe(int startx, int starty, int endx, int endy, int duration) 

説明

に一致する要素:全体でスワイプするため
TouchShortcuts
簡易メソッドを

戻り値に要素のスクロールスクリーン。

パラメータ:
startx - 開始x座標。
starty - 開始のy座標。
endx - 終了するx座標。
endy - 終了するy座標。
期間 -

例を取るために全体スワイプアクションのミリ秒単位の時間の量:

@Test 
public void swipingVertical() throws InterruptedException { 
    //Get the size of screen. 
    size = driver.manage().window().getSize(); 
    System.out.println(size); 

    //Find swipe start and end point from screen's with and height. 
    //Find starty point which is at bottom side of screen. 
    int starty = (int) (size.height * 0.80); 
    //Find endy point which is at top side of screen. 
    int endy = (int) (size.height * 0.20); 
    //Find horizontal point where you wants to swipe. It is in middle of screen width. 
    int startx = size.width/2; 
    System.out.println("starty = " + starty + " ,endy = " + endy + " , startx = " + startx); 

    //Swipe from Bottom to Top. 
    driver.swipe(startx, starty, startx, endy, 3000); 
    Thread.sleep(2000); 
    //Swipe from Top to Bottom. 
    driver.swipe(startx, endy, startx, starty, 3000); 
    Thread.sleep(2000); 
} 

これは間違いなくあなたのAppiumスクリプト

を実行するためのJavaクライアント4.0の新しいバージョンのために動作します

よろしく:
Gaurav Lad

1

Appiumのディスカッション掲示板でthis responseをチェックしてください。

基本的には、以前のスクロール方法と同じ方法があります(Android/iOS UIオートメーション)。これは、正確なニーズに合わせて独自のヘルパーを作成できることを意味します。

関連する問題