![](/img/trans.png)
[英]Xcode UI test XCTDaemonErrorDomain Code=13 while tapping on a cell
[英]Xcode UI test button not tapping
嗨,我是UI测试和swift的新手。
我要做的只是点击右上角的“+”按钮,然后点击显示的“第一个选项” 。 Xcode说我的测试成功,但我的水龙头都没有做任何事情。 这是我的代码
func test1() {
let app = XCUIApplication()
let addButtonButton = app.navigationBars["Timesheets"].buttons["add button"]
waitForElementToHittable(addButtonButton)
addButtonButton.tap()
let tablesQuery = app.tables
tablesQuery.cells.elementBoundByIndex(0).forceTap()
}
这是waitForElementToHittable()和forceTap()的定义
func waitForElementToHittable(element: XCUIElement,
file: String = #file, line: UInt = #line) {
let existsPredicate = NSPredicate(format: "hittable == true")
expectationForPredicate(existsPredicate,
evaluatedWithObject: element, handler: nil)
waitForExpectationsWithTimeout(30) { (error) -> Void in
if (error != nil) {
let message = "Failed to hit \(element) after 30 seconds."
self.recordFailureWithDescription(message,
inFile: file, atLine: line, expected: true)
}
}
}
extension XCUIElement {
func forceTap() {
if self.hittable {
self.tap()
} else {
let coordinate: XCUICoordinate = self.coordinateWithNormalizedOffset(CGVectorMake(0.0, 0.0))
coordinate.tap()
}
}
}
任何指导都将非常感谢。 谢谢。
你确实忘了启动应用程序:
let app = XCUIApplication()
app.launch() // missing in your code
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.