I am using Appium and I want to print names of the elements in the list. I am using following code
List<WebElement> list = getDriver().findElementsByXPath(getLocator(Locators.MY_ITEM));
List<String> strings = new ArrayList<>();
for (WebElement object : list) {
String text = object.getText();
logger.info(text);
if (!text.isEmpty())
strings.add(text);
}
But I am getting text
always as empty. What is the suggested approach over here. Note each element is of type UIACollectionCell
in case of iOS and on Android //android.widget.TextView[@text='%s']
From what I understand, you should be getting the text from the text
attribute, replace:
String text = object.getText();
with:
String text = object.getAttribute("text");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.