title: iOS UI Testing with device camera
body: <p>I have a suite of UITests and one test needs to use the camera. It is very flaky as if testing on device, the camera must be able to focus and get a picture the first time. It is also frustrating as I have to skip the test when running on Fastlane (or otherwise in an automated fashion using the simulator).</p>
  
  <p>What is best practice for UITesting user behaviour dependent on the camera?</p>
  
  <p>An example of my test code is below:</p>
  
  <pre><code>func testAddWithCamera() {
  
      if Platform.isSimulator {
  
          print("Test skipped as no camera on simulator")
      } else {
  
          let app = XCUIApplication()
          app.buttons["Camera"].tap()
          app.buttons["PhotoCapture"].tap()
          app.buttons["Use Photo"].tap()
      }
  }
  </code></pre>