title: How to select a picker view item in an iOS UI test in Xcode?
body: <p>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.</p>
  
  <p><img src="https://i.stack.imgur.com/hYELn.png" alt="enter image description here"></p>
  
  <p>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).</p>
  
  <pre><code>let app = XCUIApplication()
  app.launch()
  app.pickers.elementAtIndex(0).swipeUp()    
  XCTAssert(app.staticTexts["Selected: Black"].exists)
  </code></pre>
  
  <p>Another but very similar way of changing the picker view is to call <code>pressForDuration ... thenDragToElement</code>, which is not what I want.</p>
  
  <pre><code>app.pickers.elementAtIndex(0).pressForDuration(0.1, thenDragToElement: someElement)
  </code></pre>
  
  <p>When I use the UI test <strong>record</strong> function it does not record the picker view scrolling events. It does record when I tap on picker view items:</p>
  
  <pre><code>app.pickerWheels["Green"].tap()
  </code></pre>
  
  <p>but that does not actually work when the test is run (probably because it needs to scroll the picker view first before tapping).</p>
  
  <p>Here is the demo app with the test.</p>
  
  <p><a href="https://github.com/exchangegroup/PickerViewTestDemo" rel="noreferrer">https://github.com/exchangegroup/PickerViewTestDemo</a></p>
  
  <h2>Update</h2>
  
  <p>It is now possible to select a picker view since Xcode 7.0 beta 6 .</p>
  
  <pre><code>app.pickerWheels["Green"].adjustToPickerWheelValue("Yellow")
  </code></pre>