I have a picker view with few items: "Red", "Green", "Yellow", "Black". In my UI test I need to select a specific item "Green" from it. I am using the XCTest UI testing APIs that were intruduced with Xcode 7.
What I managed to do so far is to swipe the whole picker view up in the unit test. It is not ideal because it always changes the picker view to the bottom item (when swiping up).
let app = XCUIApplication()
pressForDuration ... thenDragToElement
app.pickers.elementAtIndex(0).pressForDuration(0.1, thenDragToElement: someElement)
As noted in the question's update, Xcode 7 Beta 6 added support for interacting with pickers. The newly added method
-adjustToPickerWheelValue: should be used to select items on a
let app = XCUIApplication() app.launch() app.pickerWheels.element.adjustToPickerWheelValue("Yellow")