Appium unable to get "content-desc" attribute data

12,263

Solution 1

Use "name"

property.getAttribute("name");

Solution 2

The list of accepted attribute names can be found in boolean attrbutes and string attributes.

The boolean attributes are:

  • enabled
  • checkable
  • checked
  • clickable
  • focusable
  • focused
  • longClickable
  • scrollable
  • selected
  • displayed

The string attibutes are:

  • contentDescription
  • text
  • className
  • resourceId

I tested this using the python bindings.

Credit goes to TikhomirovSergey in a github comment.

Share:
12,263
HRVHackers
Author by

HRVHackers

Updated on June 22, 2022

Comments

  • HRVHackers
    HRVHackers almost 2 years

    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)