Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appium unable to get "content-desc" attribute data

In the below case, Appium is correctly able to locate elements by class, but when we want to manipulate the data based on each element's content-desc we see an error. Why can't we get attribute for content-desc? Any advice appreciated.

    List<WebElement> arrayOfProperties2 = driver.findElementsByClassName("android.view.View");
    List<WebElement> propertyMarkerEle = new ArrayList<>();

    System.out.println("Found arrayOfProperties2 total: "+ arrayOfProperties2.size());

    for (WebElement property : arrayOfProperties2){
        String contentDesc = property.getAttribute("content-desc");
        if (contentDesc.contains("property"))
            propertyMarkerEle.add(property);

Error: Found arrayOfProperties2 total: 32
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

like image 649
HRVHackers Avatar asked Sep 25 '14 23:09

HRVHackers


People also ask

Where is element by content DESC in Appium?

Use the UI Automator API, in particular the UiSelector class to locate elements. In Appium you send the Java code, as a string, to the server, which executes it in the application's environment, returning the element or elements.

How do I write XPath in Appium?

Use the Spy icon button in order to get the Native/Web properties of all the objects on the screen. The easiest way to create a simple XPath query is by marking the wanted properties of an element (one or multiple properties can be used), right-clicking on them and then clicking on Copy XPath.

What is Appium accessibility ID?

Accessibility ID. Read a unique identifier for a UI element. For XCUITest it is the element's accessibility-id attribute. For Android it is the element's content-desc attribute.


1 Answers

Use "name"

property.getAttribute("name");

like image 83
TinyTimZamboni Avatar answered Sep 27 '22 20:09

TinyTimZamboni