2016-06-09 2 views
1

UITableViewCell 내의 단추를 두드리는 UITest를 작성하려고합니다. 재생하면이 세포를 탭으로 동일한 작업 결과,UITableViewCell의 맞춤 검색 버튼을 탭 하시겠습니까?

[[[[[XCUIApplication alloc] init].tables childrenMatchingType:XCUIElementTypeOther] elementBoundByIndex:1].otherElements[@"Problems"] tap]; 

:

enter image description here

셀을 두드리고 때 내 탭 활동을 기록하려고, 엑스 코드 라인을 생성 그 자체는 내가 원하는 것이 아닙니다.

버튼을 구체적으로 누르는 방법이 있습니까?

답변

3

사용자 지정 단추에 액세스 가능성 식별자를 설정합니다. 그런 다음 테스트를 통해 직접 액세스 할 수 있습니다.

응용 프로그램 코드 :

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = UITableViewCell() 
    cell.accessoryView = CustomButton() 
    cell.accessoryView.accessibilityIdentifier = "New Problem \(indexPath.row)" 
} 

시험 코드 :

let app = XCUIApplication() 
app.buttons["New Problem 42"].tap() 
+0

내가 화면에있는 버튼의 여러 인스턴스가 있습니다. 여전히 작동할까요? – ecatalano

+0

'indexPath.row' 사용에 대한 업데이트를 참조하십시오. –