Try xpath
xpath = “//android.widget.EditText[contains(@content-desc,‘Enter name on card’)]”
or if you want to get the value then you can try
getAttribute(‘content-desc’)
Try below will surely work -
- driver.findElementByAccessibilityId(" string value");
- xpath = ("//android.widget.EditText[@content-desc=‘login_email_input’]");
Hi @igal_epshtein,
I have no idea
But you made me curious. I just searched a bit and I think those are defined differently according to the driver used.
For UIA2 if you look in getElementAttributeValue() method under app/src/main/java/io/appium/uiautomator2/handler/GetElementAttribute.java you find out:
- “name”
- “contentDescription”
- “text”
- “className”
- “resourceId”
- “contentSize”
Then it fallback to a call to getBoolAttribute() method under app/src/main/java/io/appium/uiautomator2/model/UiObject2Element.java where you can also find:
- “enabled”
- “checkable”
- “checked”
- “clickable”
- “focusable”
- “focused”
- “longClickable”
- “scrollable”
- “selected”
- “displayed”
- “password”
Thanks !
Will try to work with them soon
HI Guys,
I have below attributes:
index 0
text Remember me?
class android.widget.CheckBox
content-desc
checkable true
checked true
clickable true
enabled true
focusable true
focused false
scrollable false
long-clickable false
password false
selected false
bounds [128,1313][827,1377]
resource-id com.cmo.compliance.android:id/remember
instance 0
I am able to get boolean attribute checked etc but not able to getAttribute(“instance”). How to get instance value?
Please help me.
- What error you get when you try to get instance value by using getAttribute method?
- Why do you even need to access instance attribute: what’s the scenario? what do you want to accomplish?
- Screenshot?
element.getAttribute(“contentDescription”) worked. But element.getAttribute(“name”) did not give the correct value. Thanks.
You probably (I hope so) using UIAutomator2, so name doesn’t work
Thank you getAttribute("name")
worked for me!
Hi, may I know whats the driver? how to setup it
.getAttribute(“content-desc”) worked for me