Xcode 9, UI Testing finding element 60 second freeze

Querying an element sometimes freezez the UI test for 60 seconds. This happens randomly and works correctly after waiting for 60 seconds.


t = 9.14s Find the Window

t = 70.20s Find the Window (retry 1)

from the console log, seems like XCUITest can't find the window.

Replies

I have same issue, when on screen presenting UIPickerView in custom UIView in property inputView from UITextField

Code Block swift
let datePicker = DatePicker()
...
textField.inputView = datePicker

where DatePicker:
Code Block swift
final class DatePicker: UIControl {
private let pickerView = UIPickerView()
override init(frame: CGRect = .zero) {
super.init(frame: frame)
setupPickerView()
...
}
private func setupPickerView() {
        addSubview(pickerView)
        pickerView.dataSource = self
        pickerView.delegate = self
...
    }
}


And in UI Test:
Code Block swift
func testExample() throws {
let app = XCUIApplication()
app.launch()
app.textFields["TheTextField"].tap()
/* After DatePicker is displayed on screen
XCUIApplication stops working at all
Can't find the window
It falls on timeout and can not collect the view hierarchy */
app.windows.element(boundBy: 0)
}


Xcode 12.2

Having the same issue as @Timbaev. I have found out that when running the application normally, the picker's titleForRow dataSource method gets called in an optimized way, calling for the visible rows and +- 10 rows. Whereas when UI Tests are run, that method gets called for all the picker rows on the main thread, which leaves the application hanging, and the UI Tests are not able to find any element. Is that the case with you and have you tried to get a solution to that @Timbaev?