2016-03-24 50 views
0

Appium版本:1.4.0.0無法向下的Android與appium滾動

操作系統:Windows 7

庫:android.AndroidDriver

selenium.WebDriver

我使用Java用於自動化與Appium

我試過下面的代碼。

driver.swipe(381, 783, 364, 218, 3000); 
driver.scrollTo("Confirm"); 
driver.scrollToExact("Confirm"); 

錯誤時使用scrollto:org.openqa.selenium.NoSuchElementException:一個元素找不到使用給定的搜索參數的網頁上。

錯誤使用時刷卡:顯示java.lang.NullPointerException

+0

是否覆蓋驅動程序的scrollTo方法?如果是,如何? – nullpointer

回答

0

我用這個代碼在IOS刷垂直:

Dimension size = driver.manage().window().getSize(); 

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; 

//Swipe from Bottom to Top. 
driver.swipe(startx, starty, startx, endy, 3000); 
makeWait(2); 

希望這將有助於ü。

0

已經創建了一個功能,刷卡(包裝)

public void scroll() throws IOException { 
       try { 
       Dimension dimensions = driver.manage().window().getSize(); 
       System.out.println("Size of Window= " +dimensions); 
       int scrollStart = (int) (dimensions.getHeight() * 0.5); 
       System.out.println("Size of scrollStart= " +scrollStart); 
       int scrollEnd = (int) (dimensions.getHeight() * 0.2); 
       System.out.println("Size of cscrollEnd= " + scrollEnd);    
       driver.swipe(0,scrollStart,0,scrollEnd,1000);   

       } catch (IOException e) { 
        // TODO Auto-generated catch block 

       } 

      } 

它添加到我們的代碼,只需在烏拉圭回合的測試用例中scroll();

+0

我得到了錯誤:java.lang.NullPointerException – user3612950

+0

我使用正確的jar文件嗎? 「Java的客戶端-2.1.0.jar」? – user3612950

+0

是的它的權利.... – karthick23

0

您可以下使用屏幕上滾動座標:

public void scrollDown() { 
    Dimension size = driver.manage().window().getSize(); 
    int x = size.width/2; 
    int starty = (int) (size.height * 0.60); 
    int endy = (int) (size.height * 0.10); 
    driver.swipe(x, starty, x, endy, 2000); 
}