我试图通过点击搜索栏中的"取消"按钮来关闭搜索字段.
测试用例未能找到取消按钮.它在Xcode 7.0.1中运行良好
我添加了谓词等待按钮出现.当我们点击"取消"按钮时,测试用例失败
let button = app.buttons[“Cancel”]
let existsPredicate = NSPredicate(format: "exists == 1")
expectationForPredicate(existsPredicate, evaluatedWithObject: button, handler: nil)
waitForExpectationsWithTimeout(5, handler: nil)
button.tap() // Failing here
Run Code Online (Sandbox Code Playgroud)
日志:
t = 7.21s Tap SearchField
t = 7.21s Wait for app to idle
t = 7.29s Find the SearchField
t = 7.29s Snapshot accessibility hierarchy for com.test.mail
t = 7.49s Find: Descendants matching type SearchField
t = 7.49s Find: Element at index 0
t = 7.49s Wait for app to idle …Run Code Online (Sandbox Code Playgroud) 使用Xcode UI测试,我无法查询UITableView中的单元格
UITableView包含3个单元格:
import UIKit
@objc class DumpTable: UITableViewController {
var objects: [NSDate] = [NSDate]()
override func viewDidLoad() {
super.viewDidLoad()
objects.append(NSDate())
objects.append(NSDate())
objects.append(NSDate())
tableView.isAccessibilityElement = true
tableView.accessibilityLabel = "Thetable"
tableView.accessibilityIdentifier = "Thetable"
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return objects.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell()
let object = objects[indexPath.row]
cell.textLabel!.text = object.description …Run Code Online (Sandbox Code Playgroud)