2014-11-21 29 views
1

我要向下滾動到頁面底部向下滾動頁面,並做一些action.Using uiautomator我已獲得以下:如何appium

index=2, 
resource-id=com.manoramaonline.arogyam:id/pager,class=android.support.v4.view.ViewPager, 
scrollable=true. 

請幫我做到這一點。

我試着用下面的code.Could任何人指出的問題?

JavascriptExecutor js = (JavascriptExecutor) driver; 
RemoteWebElement element =(RemoteWebElement)driver.findElement(By.xpath(
"//android.support.v4.view.ViewPager[@resource-id='com.manoramaonline.arogyam:id/pager']"));  
HashMap<String, String> scrollObject = new HashMap<String, String>(); 
scrollObject.put("direction", "down"); 
//i am getting error for this code 
scrollObject.put("element", element.getId()); 
js.executeScript("mobile: scroll", scrollObject); 
+0

你能添加有關您的自動化喜歡的操作系統是一些細節使用,自動化應用操作系統,你正在使用的appium版本等 – user2220762 2014-11-26 09:47:05

+0

我正在爲android應用創建腳本,appium版本是AppiumForWi ndows-1.2.4.1 – Tester 2014-12-01 09:32:20

+0

我可以使用下面的代碼向下滾動,WebElement element = driver.findElement(By.className(「android.widget.ScrollView」)); HashMap arguments = new HashMap (); arguments.put(「element」,((RemoteWebElement)element).getId()); ((JavascriptExecutor)驅動程序).executeScript(「mobile:scrollTo」,arguments);但得到異常信息:[debug]響應客戶端錯誤:{「status」:13,「value」:{「message」:「處理命令時出現未知的服務器端錯誤。」,「origValue」:「無法將元素滾動到視圖中: – Tester 2014-12-04 05:49:22

回答

0

我知道它通過以下代碼工作。

WebElement element = driver.findElement(By.className("android.widget.ScrollView")); 
    Actions actions = new Actions(driver); 
    actions.moveToElement(element); 
    // actions.click(); 
    actions.perform(); 
+0

我已經嘗試了代碼如上所述,但我得到異常** ** org.openqa.selenium.WebDriverException:尚未實現。**,我正在使用Appium Java客戶端 - 2.2和Selenium版本2.45。請問你能幫我嗎? – mra419 2015-05-10 12:01:24

+0

我有使用硒版本2.44和Java客戶端2.1.0。嘗試在設備上運行腳本。我在設備上運行腳本。 – Tester 2015-05-18 07:11:50

0
JavascriptExecutor js = (JavascriptExecutor) driver; 
      HashMap<String, String> scrollObject = new HashMap<String, String>(); 
      scrollObject.put("direction", "down"); 
      js.executeScript("mobile: scroll", scrollObject); 

此代碼將向下滾動,你可以指定你多少次想爲它通過把它變成一個for循環滾動。唯一的缺點是它是一個非特定的代碼。再次,這段代碼來自他們的一個github答案,正如我所提到的,Appium不能爲iOS做適當的滾動。至少,我沒有找到任何東西。

+0

但是,當然是一個遲到的迴應,但主要涉及到驅動程序.Scroll在Appium for iOS中完全是垃圾和不起作用。此代碼將向下滾動,您可以指定希望它通過將其放入for循環來滾動多少次。唯一的缺點是它是一個非特定的代碼。再次,這段代碼來自他們的一個github答案,正如我所提到的,Appium不能爲iOS做適當的滾動。至少,我沒有找到任何東西。 – SomeStudent 2015-08-04 18:41:56

+0

啊,呃。我將在當天晚些時候編輯它,目前正在工作。但我相信評論也可以解決這個問題。 – SomeStudent 2015-08-06 13:19:56

0

在近期更新appium「mobile:scroll」不推薦使用的情況下,以下代碼將起作用,視頻將幫助您實施。

滾動到文本:

MobileElement radioGroup = (MobileElement) wd 

.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()" 

".resourceId(\"+<listview_id>+\")).scrollIntoView(" 

"new UiSelector().text(\"+<your_text>+\"));"); 

radioGroup.click(); 

此鏈接將幫助您:https://www.youtube.com/watch?v=bT3tqaLNn-Y

-1
MobileElement radioGroup = (MobileElement) wd.findElementByAndroidUIAutomator(" 
    new UiScrollable(new UiSelector().resourceId(\"+<listview_id>+\")) 
     .scrollIntoView(new UiSelector().text(\"+<your_text>+\")); 
"); 
radioGroup.click(); 

方法從Manidroid作品對我來說完全