我正在 El Capitan (10.11) 上运行 Xcode 7。我正在使用 XCUITest 的新记录和播放功能。我使用的是 Swift,而不是 Objective-C。这是我迄今为止生成的代码:
func testButton2() {
let app = XCUIApplication()
app.tabBars.buttons["Location"].tap() //tab bar tap
app.buttons["Button"].tap() // button tap
//now verify some text appears in this tab view
}
我想验证点击按钮后 UILabel 中同一 View 中是否出现一些文本。
有什么想法吗?
我知道这里列出了一堆断言:
http://iosunittesting.com/xctest-assertions/
最佳答案
func testButton2() {
let app = XCUIApplication()
app.tabBars.buttons["Location"].tap() //tab bar tap
app.buttons["Button"].tap() // button tap
//now verify some text appears in this tab view
XCTAssertEqual(app.staticTexts.elementBoundByIndex(0).label, "some text", "should be equal") }
关于xcode - Xcode 7 中的 XCTest : how to verify some text exists in the view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38253056/