当由Xcode bot运行时,文本在文本视图中键入时,UI测试失败 [英] UI test fails when it types text into a text view when run by an Xcode bot
问题描述
我有以下XCTest UI测试,它将文本键入文本视图。
I have the following XCTest UI test that types text into a text view.
let textView = app.textViews.elementBoundByIndex(0)
textView.tap()
textView.typeText("Hello world")
当作为Xcode机器人运行时,它会为 typeText
调用显示以下错误。
When run as an Xcode bot it shows the following error for the typeText
call.
断言:UI测试失败 - 失败:等待关键事件完成超时
Assertion: UI Testing Failure - failed: Timed out waiting for key event to complete
有趣的是,当我从同一台计算机上的Xcode手动运行时,测试通过了。在升级到Xcode 7.1 / iOS 9.1之前,此测试也通过了Xcode bot。可能是问题的根源是什么?
Interestingly, when I run it manually from the Xcode on the same computer the test passes. This test also passed in Xcode bot before upgrade to Xcode 7.1 / iOS 9.1. What can be the source of the problem?
这是一个带有UI测试的独立演示:
https://github.com/exchangegroup/UITestTextViewDemo
Here is an isolated demo with the UI test: https://github.com/exchangegroup/UITestTextViewDemo
iOS 9.1模拟器,OS X 10.11.1 (15B42),Xcode 7.1(7B91b),OS X Server 5.0.15(15S4033)
iOS 9.1 Simulator, OS X 10.11.1 (15B42), Xcode 7.1 (7B91b), OS X Server 5.0.15 (15S4033)
报告给Apple。
推荐答案
我为我的案子找到了一个解决方案,我希望它对你有帮助。
I found a solution for my case and I hope it helps you as well.
在我的 setUp()
和 tearDown()
(我知道这似乎多余)我把 XCUIApplication()。terminate()
。这是确保应用程序在运行下一个测试之前终止,并且它似乎正在完成工作。
In my setUp()
and tearDown()
(seems redundant I know) I put XCUIApplication().terminate()
. This is ensuring that the app is terminated before running the next test and it seems to be doing the job.
override func setUp() {
XCUIApplication().terminate()
super.setUp()
continueAfterFailure = false
XCUIApplication().launch()
}
override func tearDown() {
super.tearDown()
XCUIApplication().terminate()
}
我向Apple提交了一个错误,但目前这让我了解了你所看到的错误。希望有所帮助!
I filed a bug with Apple but for the time being this is getting me around the error that you were seeing. Hope that helps!
这篇关于当由Xcode bot运行时,文本在文本视图中键入时,UI测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!