我如何 UI 测试 UITextField 或 UITextView 的 autocapitalizationType 属性 是否设置正确?

How can I UI test if autocapitalizationType property of a UITextField or UITextView is set properly?

假设我有一个 UITextView,我在上面设置了这些属性:

    textView.accessibilityIdentifier = "autocapitalized"
    textView.autocapitalizationType = UITextAutocapitalizationType.Sentences

现在我想 UI 测试(使用新的 XCode 7 UI 测试框架)如果 autocapitalizationType 设置正确。
为了模拟用户在 UITextView 上写字,我写了一个这样的测试:

    let app = XCUIApplication()
    let textView = app.textViews["autocapitalized"]

    textView.tap()
    textView.typeText("a") // lowercase 'cause I thought it'd be automatically uppercased but I was wrong

    XCTAssert(textView.value as! String == "A") // fails

测试会失败,所以我的问题是:有没有办法在软件键盘上模拟简单的按键操作?
我的意思是,如果我手动 运行 测试,我聚焦 textView 并在键盘上点击 "A" 它默认自动大写(因为 autocapitalizationType 属性):怎么能我使用新的 UI 测试框架自动加倍相同的测试?

点击 A 键,而不是在文本字段中键入文本。

let app = XCUIApplication()
let textView = app.textViews["autocapitalized"]

textView.tap()
app.keys["A"].tap()

如果键盘上没有显示 A 键,最后一行将失败。 如果文本字段的 autocapitalizationType 设置不正确,a键会出现。