2014-11-04 72 views
0

我是這個移動自動化的新手。我已經嘗試了下面的方法在ios7模擬器中刷卡,但他們都沒有爲我工作。如何使用appium在IOS7中滑動?

1)

HashMap<String, Integer>() map = new HashMap<String, Integer>() { 
      { 
       put("touchCount", 1); 
       put("startX",225); 
       put("startY", 500); 
       put("endX", 225); 
       put("endY", 250); 
       put("duration", 5); 
      } 
     }; 
     ((JavascriptExecutor) driver).executeScript("mobile: swipe", map); 

2)

TouchAction touchAction = new TouchAction(driver); 
     touchAction.longPress(225, 500).waitAction(3000).moveTo(225, 
     250).release(); 
     touchAction.perform(); 

3)driver.swipe(225,500,225,250,3000)

預先感謝。

回答

0

在iOS7 SIM卡中滑動存在問題,在iOS8順便說一句我沒有能夠運行滑動。只需使用scroll.You可以設定方向 「上」, 「下」, 「右」 或 「左」

的HashMap scrollObject =新的HashMap()解決了這個問題對我來說,{{

 scrollObject.put("direction",direction); 
    }}; 
     iOSDriver.executeScript("mobile: scroll", scrollObject); 
1

這是在web應用程序上刷卡的工作解決方案。我嘗試了很多解決方案,最終嘗試了這種方式。

driver.context("NATIVE_APP");//This is important for TouchAction 
TocuhAction action = new TouchAction(driver); //driver is AppiumDriver 
action.press(startX,startY); 
action.waitAction(500); //has to be >= 500 otherwise it will fail 
action.moveTo(endX,endY); 
action.release(); 
action.perform(); 
//Now change back the context 
driver.context("WEBVIEW_1"); 
//It is important to sleep for some time 
TimeUnit.SECONDS.sleep(1); 

好去..