我正在使用appium 1.6.5并尝试使用更多RelativeLayouts(0-7)访问GridView中的元素
Screenshot from uiAutomatorViewer 我已经尝试了所有可能的命令
// 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 :(得分:0)
试试这个: List icons = aDriver.findElementsByClassName(“android.widget.RelativeLayo ut”); icons .get(4).click();