how to get value of content-desc where multiple elements id or class name is same, can anybody reply with syntax, Please.
or if u need the value then
Thank you for your reply, i tried both way but unable to get the value, it says:
An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
String a=dr.findElement(By.className("//android.view.View[@content-desc=‘Abscess Overview Heading’]")).getAttribute(“content-desc”)//also tried getText().;
there is an option in UiObject, where there is a method to get the value of content description, but don’t know the syntax, you help is highly appreciated, Thanks.
try to get content-desc using attribute name so
i am able to get !!
getAttribute(“name”) works for me
I am facing same issue and able to resolve by driver.findelement(By.id(“id”)).getAttribute(“name”).
But my question is why can’t we read cont-desc like this
Is it a bug or any other logic? I need to understand this issue in depth
@Sheetal_Singh, why don’t you use uiautomator locator strategy?
Hi Mayuresh, I’m using Appium + Ruby to test Android. Since I can’t use find element by name anymore for Appium 1.5.3. How can I find the following?
I’ve tried xpath //android.view.View[@content-desc=‘result’] but I’m getting a syntax error.
Thank you for any help!!
Hi Mayuresh, it works like a charm!!! Thank you so much!!!
See this issue for an explanation why some XML, elements, and attributes can be compressed away: https://github.com/appium/java-client/issues/74#issuecomment-50886465
The reason why you cannot use getAttribute() to grab the"content-desc" value from the element is because Android UIAutomator has the option of using either a full UI XML dump or a compressed dump, decided from the start of the UIAutomator process. Appium is using the compressed dump, so while you can find any element or attribute with an XPATH call, once you have an element you can only get a subset of attributes dynamically.
getAttribute can retrieve a subset of the values, including “text”, “clickable”, “checkable”, and others…
The attributes that cannot be grabbed even though they are available in the full UI XML dump are “index”, “content-desc”, “class”, and others.
It appears that there is no way around this unless we specify UIAutomator to ALWAYS do a full UI XML dump from the beginning of the process, which would slow down the automation. This user restarts the UIAutomator server multiple times to achieve this: https://github.com/appium/java-client/issues/74#issuecomment-64672526
If anybody else has an idea about how to dynamically grab getAttribute(“content-desc”) without relying on an XPATH call (how to query against the full XML), please post in a reply how to achieve this!
Like it was said before, you can use:
But this is a poor implementation and in UIAUtomator2 it does work anymore. So better is to always use:
its working fine
i have issue with get text method i want text from the conent-Desc how can get the text
This works in c#
today i tried gettext method i got the text from content-desc
webelements properties text id class content-desc
if u want content-desc must should empy in text field then
only we get the text from content-desc otherwise we get the
text from text field ex i tried amazon app
this is amazon icon we get the text from content-desc
Hey this worked for me.
xpath = '//android.widget.Image[@content-desc="profile_pic"]'
This worked for me, thank you.
None of the below is working for me. getting null value though value is available for content-desc attribute. Any solution?