Xcode12 iOS 14 Date Picker UI Testing adjust toPickerWheelValue issue

I am getting this UI Testing error when I try to adjust the month-year calendar in new compact date picker.

Assertions: Assertion Failure at ***.swift:4: Unsupported picker wheel "2020" PickerWheel of type 6

My code is
Code Block swift
let compactDatePicker = self.app.descendants(matching: .any)["Date Picker"]
compactDatePicker.tap()
self.app.buttons["Show year picker"].tap()
self.app.pickerWheels.element(boundBy: 1).adjust(toPickerWheelValue: "2020")
self.app.pickerWheels.element(boundBy: 0).adjust(toPickerWheelValue: "September")
self.app.buttons["Hide year picker"].tap()    
let calendarDateButton = self.app.buttons.containing(NSPredicate(format: "label CONTAINS '%d %@'", 27, "September")
calendarDateButton.tap()
self.app.swipeDown()

I have no idea what this error means. I am just guessing this should be a bug in Xcode 12.0.

Anyone can help me to have a look on this?
iOS 14 uses a completely different type of date picker. Your automation will have to be rewritten to support it.
I was rewriting the automation code.
Code Block swift
/* Find the new date picker row and tap to enter new calendar view */
let compactDatePicker = self.app.descendants(matching: .any)["Date Picker"]
compactDatePicker.tap()
/* Tap top left "September 2020" button to enter month and date selection view */
self.app.buttons["Show year picker"].tap()
/* Unsupported picker wheel error throws here */
self.app.pickerWheels.element(boundBy: 1).adjust(toPickerWheelValue: "2020")

After it enters the month and year view, it becomes a pickerWheel view. I searched elements in debugger console, it is also shown as a pickerWheel but I cannot adjust it. I also tried this implementation in Xcode 12.0.1 and the issue still exists.

I am just wondering whether this is a bug in Xcode 12 or there is another solution to adjust this type 6 pickerWheel.

I tried my implementation in Xcode 12.1 GM and this issue still exists. I can find there are two picker wheels but the error throws when I try to adjust them.
There still doesn't seem to be a supported method of changing the new date picker wheels as of Xcode 12.1.

I've come up with this method to get around the issue:

Code Block
func adjustDatePicker(wheel: XCUIElement, to newValue: String) -> Bool {
let x = wheel.frame.width / 2.0
let y = wheel.frame.height / 2.0
// each wheel notch is about 30px high, so tapping y - 30 rotates up. y + 30 rotates down.
var offset: CGFloat = -30.0
var reversed = false
let previousValue = wheel.value as? String
while wheel.value as? String != newValue {
wheel.coordinate(withNormalizedOffset: .zero).withOffset(CGVector(dx: x, dy: y + offset)).tap()
let briefWait = expectation(description: "Wait for wheel to rotate")
briefWait.isInverted = true
wait(for: [briefWait], timeout: 0.25)
if previousValue == wheel.value as? String {
if reversed {
// we already tried reversing, can't find the desired value
break
}
// we didn't move the wheel. try reversing direction
offset = 30.0
reversed = true
}
}
return wheel.value as? String == newValue
}

Hello everybody,

Does anybody have an update on this? I am struggling with Version 12.5 (12E262) and still the crash occurs, and I still can't scroll the wheels programmatically fast.

I need an answer to this too.

Xcode12 iOS 14 Date Picker UI Testing adjust toPickerWheelValue issue
 
 
Q