[Solved] Get content-desc from element in UIAutomator2

Hi,

Using appium 1.6.3 with UIAutomator2, how can we get the content-desc from an element.

In old code I have something similar to:

driver.findElement(By.id("my_id")).getAttribute("name")

Now doing that is giving me the same result as getAttribute(“text”).

I’m aware that I can do (or similar via XPath):

driver.findElementByAccessibilityId("my_content_desc");

But in this case I already have the element and just want to know the content-desc.

Thanks

@Sravanmedarapu told me the answer in the issue I had created (https://github.com/appium/appium/issues/7612):

Using driver.findElement(By.id("my_id")).getAttribute("contentDescription")

Thanks