3

I am trying to write a test for UIPickerView to pick certain values. I use picker.adjust(toPickerWheelValue: pickValue) to do so. But the problem is that for some reason this only swipes picker by one value.

For example on the gif you can see that initial value was 52, then I called picker.adjust(toPickerWheelValue: "15") and it became 51 instead of 15, then I called it again and it became 50:

wrong picker behaviour

So the pattern is that it only changes it by one value up or down closer to the desired value.

What is the problem here?

Simon Moshenko
  • 2,028
  • 1
  • 15
  • 36
  • Could you paste the relevant code? Much better readable than the screenshot. – koen Dec 09 '19 at 19:00
  • You are pausing during a UI test and giving manual LLDB commands? – matt Dec 09 '19 at 19:01
  • @matt yes. To show interactively how it behaves – Simon Moshenko Dec 09 '19 at 19:05
  • @koen I am calling `adjust(toPickerWheelValue: "15")` on the `pickerWheel element` – Simon Moshenko Dec 09 '19 at 19:06
  • @Simon Moshenko: apple docs say /*! Changes the displayed value for the picker wheel. Will generate a test failure if the specified value is not available. */ open func adjust(toPickerWheelValue pickerWheelValue: String) } is the expected value available? What is the error generated at runtime (not lldb)? It sure looks like you are calling this correctly to me.. – ablarg Dec 09 '19 at 20:16
  • @ablarg yes, it has the expected value. In fact if I do these actions in a loop, it eventually comes to that value and does nothing from it. So it know that the value is there and the value is correct. Also there is no error while I run the actual tests. – Simon Moshenko Dec 09 '19 at 20:31
  • Sadly, still not fixed as of Aug 31, 2021. – christophercotton Aug 31 '21 at 16:57

1 Answers1

0

Referencing with initial value works for me. So my code looks like this:

app.pickerWheels["52"].adjust(toPickerWheelValue: "15")