As debugDescription returns the XCUIElement UI Tree and this if of type String. Want to fetch specific information based upon parameters like label :[String] will return all the label values, find_Application - will return the bundleID etc
Asked
Active
Viewed 67 times
0
-
What have you tried? I'd suggest not attempting to parse that output and use the tools that are given to you via XCUITest. Think: arrays, looping on those arrays, building another array? – Mike Collins Jan 31 '23 at 14:39
-
Hi @MikeCollins the issue is I want to be independent of the synchronization issues that are encountered while performing actions on XCUIElement via XCUIElement query . I tried various possible ways to interact like using predicates or descendants(matching: .any) etc. I want to store all the UI information displayed on screen (captured via debuDescription). Parse through it and get the required line items like labels, title etc – Indrajit Feb 01 '23 at 00:44
-
It sounds like your mind is made up on your method. You're going to have to write your own parser; this does not exist. When faced with similar I often ask myself "Why has no-one attempted to do this before?" – Mike Collins Feb 01 '23 at 13:48
1 Answers
0
You can use element.snapshot().dictionaryRepresentation
which gives a parsed version of output of element.debugDescription
or element.snapshotDescription
.
You can use element.snapshot().children
to get the child element's snapshots iteratively if you want to create your own parser.

Prakash Saravanan
- 586
- 5
- 15