在我的iOS中,我正在使用XCUITest
實現UITests。從我有Swift 2.3開始,它工作得很好,但是在將應用程序更新到Swift之後,像tap()
這樣的基本操作不再起作用。iOS UITests無法在Swift 3更新後執行基本操作
只是一個簡單的代碼,不工作了:
XCUIApplication().buttons["orgMenu"].tap()
拋出
Assertion Failure: <unknown>:0: UI Testing Failure - Failure getting snapshot Error Domain=XCTestManagerErrorDomain Code=9 "Error -25204 getting snapshot for element <AXUIElement 0x7f8297d15a50> {pid=32375}" UserInfo={NSLocalizedDescription=Error -25204 getting snapshot for element <AXUIElement 0x7f8297d15a50> {pid=32375}}
按鈕的名稱是正確的:如果我記錄測試,然後點擊按鈕線以上正是我所得到的。
的按鈕在視圖中,因爲我(這個手動倆都試圖通過一個斷點,並以編程方式:
let exists = NSPredicate(format: "exists == 1")
expectation(for: exists, evaluatedWith: XCUIApplication().buttons["orgMenu"], handler: nil
waitForExpectations(timeout: time, handler: nil)
)等待它的存在
。不管怎麼樣,在Swift 3之前工作。 任何想法?提前致謝!
你能上的按鈕在模擬器手動相同的生成挖掘,而不應用程序崩潰? – Oletha
@Oletha,是的,我可以 –