Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 4 pickerWheel.adjust unable to find current value 'Mai 4' in possible values

I want to write a test and I need to adjust my pickerWheel. My pickerWheel has more than one row and I access it with:

pickerWheels[0].adjust(toPickerWheelValue: "1. Mai")

It throws me an error:

Assertion Failure: :0: Internal error: unable to find current value 'Mai 4' in possible values ... 4. Mai

So 'Mai 4' actually is in the possible Values but with a wrong format. Is there any way to fix this?

I have already read https://forums.developer.apple.com/thread/16104 but .adjust is working fine for my different rows.

like image 496
Godlike Avatar asked Nov 15 '25 14:11

Godlike


1 Answers

This is an old issue with UIPickerView implementations using a viewForRow override in lieu of titleForRow. It goes back to 2014 at least and has no solution as of August 2019: Apple Developer Thread

One easy fix would be to implement the picker's titleForRow override for UI testing and revert back to the typically somewhat more involved viewForRow method in production.

As an alternative, if you can get away with only the first and last entries in a picker view test, use the swipeUp() and swipeDown() methods. These will select the first or last items respectively regardless of text or number of fields. Something like:

let pickerWheel = app.pickers.children(matching: .pickerWheel).element
    pickerWheel.swipeUp()
    pickerWheel.tap()

But adjustToPickerWheelValue is entirely and totally broken. The current radar entry is: pickerView tests fail

like image 85
caxix Avatar answered Nov 18 '25 07:11

caxix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!