问题
I beginner test automation on Android by Appium. I use IUAtomatorviewer to get eLement from Android Application But i think my applicatoin is from customs UI. i see that is android.support.v7.widget.RecyclerView / android.view.View in [android.view.View] element, there no text or other informatoin
i see it include TextView, Image... same a item in listview
Here is my code
AndroidElement el = driver.findElement(By.id(io.***.vodi:id/message_list_item_chat_id));
AndroidElement el2 = (AndroidElement) el.findElementByClassName("android.view.View");
el2.getText(); //result is blank
el2.getAttribute("text") //result is blank
so how do i get text inner [android.view.View] ? or attribute of View
Here image of UIAutomatorviewer
回答1:
Get the "recycler view" by its resource-id. You can then get the different view's inside and select the 4th one to view "view #4".
回答2:
I was also facing the same issue in getting text from android view. below code helpful for me:
Get all your element in a list :
List<WebElement> allChats : driver.findElements(By.xpath("//*[@class='android.view.View']"));
Then iterate through for loop and get the text using name
attribute
for(WebElement chat : allChats)
{
System.out.println(chat.getAttribute("name"));
}
来源:https://stackoverflow.com/questions/36497486/appium-automation-test-how-to-get-element-or-text-from-custom-ui-in-android-an