Using XCode UI Test is there any way we can adjust iOS picker wheel to generated index Value or get the text of index value and adjust the picker wheel. I was able to get the index value using below code. But unable to get the value of the index value.
let picker = app.pickerWheels.element(boundBy: 1).otherElements.count
print(picker)
let randomNumber = arc4random_uniform((UInt32(picker)))
print(randomNumber)
Using the count of the picker wheel I am generating a random value from that. With the index number of randomNumber I am trying to get the value. Is there any way I can get the value of the index and adjust the picker wheel to that value.
This is how I handle pickers in my XCTest UI testing framework.
I have an object (
PickerState
) which can represent the state of a picker wheel, which is populated using the value of the picker wheel, which is in the format"Some value, 4 of 5"
. ThegetPickerState
method converts the value String into aPickerState
object.generateRandomNewPickerPosition
generates a random index for the picker to move to, ensuring that the picker's current position is not returned.I then use extension methods on XCUIElement to move to the randomly-generated value in
changePickerSelection
.