Prasetyo Budi
Prasetyo Budi

Reputation: 96

ui test xcode, handle datepicker

i really stuck at this problem i cant swipe and then select the year at this datepicker, maybe some experienced on automation can give solution this tupe of datepicker i wabt to handle

i had code from result of recorded test like below,

let datePickersQuery = app.datePickers
    let pickerWheel = datePickersQuery.pickerWheels["2000"]
    pickerWheel.tap()
    pickerWheel.

    let pickerWheel2 = datePickersQuery.pickerWheels["1996"]
    pickerWheel2.tap()

but still force close when running the test

Upvotes: 0

Views: 1420

Answers (1)

atgrubb
atgrubb

Reputation: 1203

You interact with date pickers a little differently and I have never seen recorded tests "get it right". You should use app.datePickers["Your matcher"].adjust(toPickerWheelValue: <String>) in order to set a value for a picker.

If you're having trouble with your date picker query, you can specify the index of which picker wheel you want to set by app.datePickers.element(boundBy: <UInt>).

Here's the link to the apple reference doc https://developer.apple.com/reference/xctest/xcuielement/1618672-adjust

Upvotes: 2

Related Questions