2017-08-24 24 views
0

我使用appium 1.6.5,並試圖訪問一個元素在GridView與如何訪問一個元素在GridView控件更rRelativeLayouts

Screenshot from uiAutomatorViewer 我已經嘗試過多種RelativeLayouts(0-7)中的所有可能的命令

// aDriver.findElementsByClassName("android.widget.RelativeLayout").get(4) 
/* 
List<MobileElement> icons = aDriver.findElementsByClassName("\"android.widget.RelativeLayout\""); 

icons.get(4).click(); 
*/ 

    aDriver.findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.RelativeLayout\").instance(4)").click(); 
// INFO: Also using index instead of instance did not hel UiSelector().className(\"android.widget.RelativeLayout\").index(4)").click() 

,但沒有成功,我得到以下錯誤

[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().className(\"android.widget.RelativeLayo 
ut\").instance(4)","context":"","multiple":false}} 
[HTTP] <-- POST /wd/hub/session/320ad077-e2fb-4304-9017-bb7aaba0ae1b/element - - ms - - 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().className(\"android.widget.Re 
lativeLayout\").instance(4)","context":"","multiple":false}} 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().className("android.widget.RelativeLayout").instance(4)' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: false 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().className("android.widget.RelativeLayout").instance(4) 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: java.lang.Class<T> arg: "android.widget.RelativeLayout" 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: class java.lang.String arg: "android.widget.RelativeLayout" 
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: int arg: 4 

希望得到任何支持 謝謝

+0

List icons = aDriver.findElementsByClassName(「android.widget.RelativeLayout」); 圖標.get(4).click(); – shiv

+0

感謝您的回答。 我試過這個也是一樣的。 – AKADO

+0

問題是,我有一個登錄掩碼,並輸入憑證後,點擊輸入一個吐司消息出現,並終止到Android主屏幕,因爲這可能是元素沒有找到(該元素是在下一頁將不會顯示) 我也增加了等待時間,但一些如何後點擊輸入按鈕下一頁沒有顯示和應用程序終止到Android主屏幕 – AKADO

回答

0

試試這個: List icons = aDriver.findElementsByClassName(「android.widget.RelativeLayo ut」);圖標.get(4).click();