당신은 접근성 식별자를 설정하여 직접 버튼에 액세스 할 수 있습니다. 테이블 예제에서 테이블 뷰의 데이터 소스에서 그렇게 할 수 있습니다.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(Cell.Identifier, forIndexPath: indexPath)
cell.accessoryView = UIButton() // your custom button
cell.accessoryView?.accessibilityIdentifier = "Cell \(indexPath.row + 1) Button"
return cell
}
그런 다음 UI 테스트에서 각 버튼을 개별적으로 탭할 수 있습니다.
let app = XCUIApplication()
let firstAccessoryButton = app.buttons["Cell 1 Button"]
firstAccessoryButton.tap()
http://stackoverflow.com/a/34923025/5135218 (accessibilityIdentifier) – Che