android attributes

2,432 views
Skip to first unread message

Teemu Kanstrén

unread,
Oct 19, 2013, 4:26:39 PM10/19/13
to appium-...@googlegroups.com
Hello,

 Is there a list of what attributes I can access on Android UI elements from Appium? I would like to read at least the "content-desc" value but why not the rest of the info in the "Node Detail" view of uiautomatorviewer. I noticed previously some discussion on using find(By.name("content-desc")) to find a component with specific value but this is not quite what I need. I have some dynamic content and would prefer to read the attributes to get a better idea which of the elements I find is which.. Any ideas?

Thanks,
Teemu

Vic Wong

unread,
Oct 19, 2013, 8:28:28 PM10/19/13
to appium-...@googlegroups.com
Not sure about appium's native android automation engine, If you're using selendroid (by setting device=selendroid in your capabilities), the supported locators are listed here:
http://selendroid.io/native.html

It supports xpath, so you can technically search by attributes with expressions like By.xpath("//SearchBox[@id='search_box']")

-v

shikha agrawal

unread,
Oct 21, 2013, 5:07:02 AM10/21/13
to appium-...@googlegroups.com
Hi Teemu,

I faced the similar issue as yours and tried to get the value of the content-desc using driver.findelement(By.className("<className>")).getAttribute("content-desc") but it returned null everytime. Please let me know if you happen to find out a way to read the value of the dynamic properties.

Thanks,
Shikha

Jonathan Lipps

unread,
Oct 21, 2013, 10:49:49 AM10/21/13
to shikha agrawal, appium-...@googlegroups.com
It's this:

driver.findelement(By.className("<className>")).getAttribute("name")

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Teemu Kanstrén

unread,
Oct 21, 2013, 11:48:30 AM10/21/13
to appium-...@googlegroups.com, shikha agrawal
Thanks. This seems to work. 

Also, I had a look at the Appium source so it seems the supported attributes are "content-desc" with "name", which gives the content-desc if set and "text" attribute value if "content-desc" is not set. Other supported string attributes to query as far as I see are "text" and "className". And a whole bunch of boolean attributes are supported as well. It seems Appium supports most of the attributes available in UIAutomators UIObject so I guess I just got confused with the attribute naming of content-desc here.

Maybe some basic API doc would be nice to document all these. But I got this one sorted now, so thanks..

Teemu
Reply all
Reply to author
Forward
0 new messages