您的 Appium 版本是什么?可以用Appium Inspector打开看看和UI Automator Viewer有没有区别?
无论如何...试试这个
#Can't see at your screenshot the whole resource-id so I put what I see.
driver.find_element_by_xpath("//android.view.View[@resource-id='rptRole__ctl0_rptCommunicationlt...']")
#You could also try these two options:
driver.find_element_by_xpath("//android.view.View[@content-desc='1_gr_selected_stores_flex_update.xls']")
driver.find_element_by_xpath("//android.view.View[@text='1_gr_selected_stores_flex_update.xls']")
如果这些都不起作用,您将必须提供更多信息
Appium 不支持 ID 中包含 $ 之类的内容。可以贴一下完整的ID吗? 请使用 findElementById 方法尝试如下:
driver.findElementById("alertTitle");
如果不起作用,请使用类名查找元素并使用索引来定位元素。
List<WebElement> allElements=driver.findElementsByClassName("android.view.View");
并使用上面列表中的索引获取元素。
WebElement yourElement= allElements.get(Required_Index);
下面的代码有效。
driver.findElementsByXPath("//android.view.View[contains(@resource-id,'rptRole')]").click();