Reputation: 85
I am new to iOS and writing a UI test case for a screen. The thing is, I want to write such a test case where I want to test same behavior for a particular type of UIElement (for eg, same behavior for button type). So instead of writing tests for different screens I wanted to know if there's some way in XCUI or any other framework where we can get all UIElements present on the screen in some data structure. Thanks
Upvotes: 2
Views: 1446
Reputation: 2273
You can get such data (elements, their labels, types, and other properties) with snapshot()
method. You will get a tree of XCUIElementSnapshot
. Also, you can get a dictionary representation.
Start reading documentation from here
https://developer.apple.com/documentation/xctest/xcuielementsnapshotproviding
Upvotes: 2