2016-09-23 69 views

回答

1

我的例子是蟒蛇,但它會爲Java的工作,以及只使用Java語法找到元素像

driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("**/Put some text which is at bottom of screen to scroll screen/**").instance(0))') 

更多的細節,你可以去通的https://developer.android.com/reference/android/support/test/uiautomator/UiScrollable.htmlhttps://developer.android.com/training/testing/ui-testing/uiautomator-testing.html

+0

工作完美,做得很好 – bkapVT

0

用戶揮動方法如下:

driver.swipe(startx, starty, endx, endy, duration); 

例如向下滑動

driver.swipe(100, 100, 100, 900, 3000); 

根據您可以更改x和y座標。

0

你可以試試這個下面的代碼,我在設置頁面上嘗試這種代碼..

AppiumDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap1); 
driver.scrollTo("About phone"); 

傳遞字符串,它存在於你的應用程序頁面的底部。

driver.scrollTo("Enter your value"); 

使用適當的等待語句。

0
@Test 
    public void testScroll()throws Exception 
    { 
     for(int i=0;i<4;i++) 
     { 
      Thread.sleep(2000); 
      if (driver.findElement(By.name("end_item")).isDisplayed()) 
      { 
       driver.findElement(By.name("end_item")).click(); 
       break; 
      } 
      else 
      { 
       verticalScroll(); 
      } 

     } 
    } 
    public void verticalScroll() 
    { 
     size=driver.manage().window().getSize(); 
     int y_start=(int)(size.height*0.60); 
     int y_end=(int)(size.height*0.30); 
     int x=size.width/2; 
     driver.swipe(x,y_start,x,y_end,4000); 
    } 

上面的例子使用垂直滾動,它是基於在這個博客給出了水平滾動http://qaautomated.blogspot.in/2016/02/how-to-do-horizontal-scroll-in-appium.html我希望這對你的作品的例子。

相關問題