[英]How can I tell which custom UITableViewCell's UIButton has been tapped?
[英]How can I control the time after an UIButton has been tapped to prepare for next action in UI Testing with Xcode
我在Xcode 7上使用UI測試,但是有一些問題。 當我記錄UI測試時,Xcode將中文翻譯為大寫的“ U”,並顯示錯誤。 和ui測試代碼
XCUIApplication *app = [[XCUIApplication alloc] init];
[app.navigationBars[@"\u5934\u6761"].images[@"new_not_login30"] tap];
XCUIElementQuery *tablesQuery = app.tables;
[tablesQuery.cells.staticTexts[@"\u6211\u7684\u864e\u94b1"] tap];
問題是:點擊圖像后,有一個動畫顯示帶有UITableView的邊欄或顯示UIAlertController,但是我無法處理持續時間。 實際上,在動畫中,測試會繼續找到要匹配的下一個元素,但這些元素不存在或不會生成。 因此,測試始終會失敗。 有什么辦法可以回答這個問題嗎? 請幫我。 謝謝。
嘗試使用ExpectationForPredicate。 我不知道Objective-C中的語法。 但這是迅速的一部分代碼:
let app = XCUIApplication()
app.navigationBars["\u5934\u6761"].images["new_not_login30"].tap()
let label = app.cells.staticTexts["\u6211\u7684\u864e\u94b1"]
let exists = NSPredicate(format: "exists == 1")
expectationForPredicate(exists, evaluatedWithObject: label) {
// If the label exists, also check that it is enabled
if label.enabled {
label.tap()
return true
} else {
return false
}
}
waitForExpectationsWithTimeout(5) { error in
if (error != nil) { assertion ....}
}
只需在Objective-C中翻譯此代碼即可。
干杯
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.