2016-05-05 21 views
1

私のネイティブAndroidアプリでは、appiumにネイティブアプリをスクロールさせるために過去2週間試しています。私はその後、driver.scrollTo("Accounts"); を試してみましたが、私は私が発見した、このエラーAndroidでのスクロールに関する問題Appiumを使用したネイティブアプリ

[org.openqa.selenium.WebDriverException: CATCH_ALL: io.selendroid.server.common.exceptions.SelendroidException: method (by) not found: -android uiautomator 

や他の多くの例を得ました。何も動作していないようです。これは私が試した最新の例です。

appium 1.5.2とappium javaクライアントのバージョン「3.3.0」を使用しています。次のコードを実行しようとすると。

TouchAction tAction=new TouchAction(driver); 
    int startx = driver.findElement(By.id("line_chart_line_chart")).getLocation().getX(); 
    int starty = driver.findElement(By.id("line_chart_line_chart")).getLocation().getY(); 
    int endx = driver.findElement(By.id("actionBarLogo")).getLocation().getX(); 
    int endy = driver.findElement(By.id("actionBarLogo")).getLocation().getY(); 
    System.out.println(startx + " ::::::: " + starty + " ::::::: " + endx + " ::::::: " + endy); 
    // This is what the console printed out startX=560 ::::::: starty=1420 ::::::: endx=560 ::::::: endy=240 
    //First tap on the screen and swipe up using moveTo function 
    tAction.press(startx,starty).moveTo(endx,endy).release().perform(); 

は、それから私は私が何をすべきか上の損失で午前、このエラーメッセージ

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy 
error: Could not proxy command to remote server. Original error: 404 - undefined (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 27 milliseconds 

を取得します。要素をクリックするには、それを画面上に表示する必要があります。この要素を画面に表示するには、その要素までスクロールする必要があります。

私が間違っていることはありますか?私はそれを理解できないようです。

答えて

1

あなたはこの方法ではUiAutomatorをサポートしていませんSelendroidモードを、使用していました。 あなたのappiumの実行モードをUiAutomatorに変更するには、希望する機能をautomationNameに変更してAppium

0

この関数は、あなたのケースでそれを呼び出すときに、elementNameの "Accounts"に入れられます。以下のような

public static void scrollToElementAndroid(AndroidDriver driver, String elementName, boolean scrollDown) { 
    String listID = ((RemoteWebElement) driver.findElementByAndroidUIAutomator("new UiSelector().className(android.widget.ListView)")).getId(); 
    String direction; 
    if (scrollDown) { 
     direction = "down"; 
    } else { 
     direction = "up"; 
    } 
    HashMap<String, String> scrollObject = new HashMap<String, String>(); 
    scrollObject.put("direction", direction); 
    scrollObject.put("element", listID); 
    scrollObject.put("text", elementName); 
    driver.executeScript("mobile: scrollTo", scrollObject); 
} 
+0

ありがとうございます。私はあなたが言ったことを試みたが、次のエラーが出た_org.openqa.selenium.WebDriverException:コマンドを処理中に不明なサーバー側エラーが発生しました。元のエラー:プロキシできませんでした。プロキシエラー:リモートサーバーにコマンドをプロキシできませんでした。元のエラー:404 - 未定義(警告:サーバはスタックトレース情報を提供しませんでした) コマンドの継続時間またはタイムアウト:14ミリ秒_私が間違っていることは何ですか? – user2040060

+0

あなたのデバイスで他のスクリプトを実行できますか、それとも関数を呼び出す場所でクラッシュしますか?あなたの要素が表示されている場所にスクロールさせるためにちょっと遊んだりする必要があるかもしれませんが、driver.swipe(start_x、start_y、end_x、end_y、duration)を試すこともできます。 – Chris

+0

次のコードを実行したとき*** driver.findElement(By.id( "login_username")))sendKeys( "UserID"); \t Thread.sleep(5000); \t MobileConfig.driver.findElement(By。 id( "User_Password"))。sendKeys( "Password"); \t thread.sleep(5000); \t driver.findElement(By.id( "login_button"))。click(); \t Thread.sleep(5000); \t driver.swipe(560,1420,560,240,2000); ***コードのすべての行は、driver.swipe行を除いて正常に実行されます。私はこのエラーを取得するorg.openqa.selenium.WebDriverException:Originコマンドを処理中に不明なサーバー側エラーが発生しました。プロキシできませんでした。プロキシエラー:次のcommenのcont – user2040060

0

利用コード:

Dimension size = driver.manage().window().getSize(); 
int x = size.width/2; 
int endy = (int) (size.height * 0.75); 
int starty = (int) (size.height * 0.20); 
driver.swipe(x, starty, x, endy, 1000); 
+0

*** Driver.swipeコマンドは、私が抱えている問題です。***私は自分のコードでこのコマンドを実行しようとすると、いつでもこのエラーが発生します。コマンドを処理中に不明なサーバー側エラーが発生しました。元のエラー:プロキシできませんでした。プロキシエラー:リモートサーバーにコマンドをプロキシできませんでした。元のエラー:404 - 未定義(警告:サーバはスタックトレース情報を提供していませんでした) コマンドの継続時間またはタイムアウト:30ミリ秒 " – user2040060

関連する問題