I'm making a UI Test for an iOS app. I'm having trouble finding out how to use automated testing for a date picker. Right now I'm stuck trying to find the date picker itself so I can change the values.
I've searched many threads regarding this issue but have found nothing.
If anyone has any insight to this it would be much appreciated. Thanks!
To get started, I'd advise you to use the "Record UI Test" button in Xcode to easily find out how to access the UIDatePicker
in the UI Test.
For a simple UIDatePicker
in date
mode, changing the date is as simple as:
let datePickers = XCUIApplication().datePickers
datePickers.pickerWheels.element(boundBy: 0).adjust(toPickerWheelValue: "June")
datePickers.pickerWheels.element(boundBy: 1).adjust(toPickerWheelValue: "1")
datePickers.pickerWheels.element(boundBy: 2).adjust(toPickerWheelValue: "2015")
If the datePicker is connected to a UILabel
, you could then check if the text in the label has been updated correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With