I'm writing the UI tests for an application that contains huge cells(~ 1000) in its tableview. Trying to access the cell elements will show the below error:
Failed to get matching snapshots: Timed out while evaluating UI query.
Scenarios:
- If I try to get the cells count by
XCUIApplication().tables.firstMatch.cells.count
, it throws the exception - Printing
XCUIApplication().debugDescription
for the first time prints the whole hierarchy (though, it takes ~10secs to print) - After that, If I try to print the exact same line
XCUIApplication().debugDescription
, throws an exception
I can not check the cells counts and can't able to access the cell elements. The system is trying to evaluate all UI elements whenever I access an element in the XCUIApplication()
.
This is the expected behaviour, so I thought of making a copy of XCUIApplication()
data locally and deal with my queries with that locally saved instance. So, I tried this:
private lazy var dummyApp: XCUIApplication = {
return XCUIApplication()
}()
Here, I used a lazy variable(because I want to call the XCUIApplication()
only once to stop the system from taking the snapshots) that returns XCUIApplication()
instance and tried to print the cell counts like:
dummyApp.tables.firstMatch.cells.count
This also throwing the same error.
Question:
Is there a way to save XCUIApplication()
's whole structure with a local variable? Or can I stop/extend the snapshot process before accessing an element?
P.S: I'm using Xcode 11.3.1. I'm facing this issue for a long time. Posting this problem as a separate question since XCUITest changed its interaction with the application from Xcode 9.