---
title: "Xcode UI testing"
slug: xcode-ui-testing
section: tech
date: 2015-06-09T18:20:00.000Z
canonical: https://roland.leth.ro/blog/tech/xcode-ui-testing
---

This is really, really awesome. Run your app and press the record button (next to the enable/disable breakpoints): as you navigate your app, code will be automatically generated. A quick test for [LTHMonthYearPickerView](https://github.com/rolandleth/LTHMonthYearPickerView):

```swift
let app = XCUIApplication()
let toolbar = app.toolbars

app.pickerWheels["2015, 46 of 91"].swipeUp()
toolbar.buttons["Done"].tap()

let textField = app.children(matching: .window)
	.element(boundBy: 0)
	.children(matching: .textField)
	.element(boundBy: 0)

XCTAssertTrue(textField.value as? String == "June / 2034")
XCTAssertFalse(textField.value as? String == "June / 2033")
```

The `value` property is, as described in the documentation:

```text
The raw value attribute of the element. Depending on the element, the actual type can vary.
```