1
嗨我是新來的UI測試和迅速。Xcode UI測試按鈕不點擊
我想要做的只是點擊右上角的"+"按鈕,然後點擊顯示的"first option"。 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()
}
}
}
任何指導,將不勝感激的定義。謝謝。