get all elements

163 views
Skip to first unread message

Chris Fairclough

unread,
Aug 8, 2014, 7:14:16 AM8/8/14
to appium-...@googlegroups.com
I am trying to retrieve a list of elements by the xpath //* to get all elements in the heirarchy. 
This is so that my code can process a number of possibilities across different devices at this point in the test.

List<WebElement> oElems = driver.findElements(By.xpath("//*"));

It's not working on a HTC one with the error message

debug: Pushing command to appium work queue: ["find",{"strategy":"index paths","selector":",/0,/0/0","multiple":true}]
debug: [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"index paths","selector":",/0,/0/0","multiple":true}}
debug: [BOOTSTRAP] [debug] Got command of type ACTION
debug: [BOOTSTRAP] [debug] Got command action: find
debug: [BOOTSTRAP] [debug] Finding ,/0,/0/0 using INDEX_PATHS with the contextId: null multiple: true
debug: [BOOTSTRAP] [debug] Returning result: {"status":13}
debug: Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command."},"sessionId":"d607fe8d-a731-46b1-b22c-443ca28d7f39"}

And then it's throwing an exception back to the java.
Any idea how I can get this to work?

Chris Fairclough

unread,
Aug 8, 2014, 7:44:34 AM8/8/14
to appium-...@googlegroups.com
It seems that the xpath selector is not going to work for me - 
but I still want to find all elements - by.name("*") and by.classname("*") don't work either although they do not crash, they just return 0 elements.

Isaac Murchie

unread,
Aug 8, 2014, 5:57:35 PM8/8/14
to Chris Fairclough, appium-...@googlegroups.com
You can try using the UIAutomator API. Something like `driver.elementsByAndroidUIAutomator('new UiSelector()')`. I don't know the syntax in Java.


--
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/d/optout.

Pop Vasile

unread,
Aug 11, 2014, 4:34:49 AM8/11/14
to appium-...@googlegroups.com, fair...@gmail.com
This is one way to do it in Java:
List<WebElement> list = driver.findElementsByAndroidUIAutomator("new UiSelector().classNameMatches(\".*\")")

Chris Fairclough

unread,
Aug 11, 2014, 8:36:00 AM8/11/14
to appium-...@googlegroups.com, fair...@gmail.com
Thanks guys!

Chris Fairclough

unread,
Aug 11, 2014, 9:01:43 AM8/11/14
to appium-...@googlegroups.com, fair...@gmail.com
I have new problem now !
Any chance you guys could look at this issue too ?

fora...@gmail.com

unread,
Aug 11, 2014, 1:25:19 PM8/11/14
to appium-...@googlegroups.com, fair...@gmail.com
Hi Chris,

I  saw in other post that your java Appium setting is at least running mine is not running can you please share your Opium  set-ups including capabilities.

Thanks,

Jonah Stiennon

unread,
Aug 11, 2014, 2:07:16 PM8/11/14
to appium-...@googlegroups.com, fair...@gmail.com
btw: Getting all elements by XPath is fixed in version 1.2.1

Chris Fairclough

unread,
Aug 11, 2014, 7:01:00 PM8/11/14
to appium-...@googlegroups.com
I don't have any opium set-ups, sorry can't help you, check the documentation for instructions on capabilities. 
BTW the appiumdevicename is deviceclass in ios and on android it's deviceid if that helps.
Reply all
Reply to author
Forward
0 new messages