2016-09-13 2 views
0

내 응용 프로그램에 대한 내 XCUITests를 작성 중이며 현재 응용 프로그램 경고를 닫을 수있는 최상의 솔루션을 찾는 데 어려움이 있습니다. 두 세트의 알림이 있습니다. 하나는 notifications이고 새로 설치를 시작할 때 나타나는 팝업이며, 두 번째는 신선한 설치 후 내 앱의 근처 탭으로 이동할 때 location 경고입니다. 내가여러 경고 닫기 XCUITesing

let alert = app.alerts["\u{201c}VoucherCodes\u{201d} Would Like to Send You Notifcations"].collectionViews.buttons["OK"] 
    if alert.exists{ 
     alert.tap() 
    } 

하지만 성공을 사용하여 시도했다, 나는 또한에 systemAlertMonitorToken를 사용하여 시도 내 내 setUp()

systemAlertMonitorToken = addUIInterruptionMonitorWithDescription(systemAlertHandlerDescription) { (alert) -> Bool in 
     if alert.buttons.matchingIdentifier("OK").count > 0 { 
      alert.buttons["OK"].tap() 
      return true 
     } else { 
      return false 
     } 
    } 

는 사람이 어떤 제안이 나 내가 내가 해결할 수 잘못 가고있는 곳을 지적 하는가 이거 고마워.

+0

가능한 복제 [엑스 코드 7 UI 테스트 : 코드에서 시스템 경고의 시리즈를 취소하는 방법] (http://stackoverflow.com/questions/32148965/xcode-7-ui-testing-how-to-dismiss-a-series-of-system-alerts-in-code) –

+0

이 질문은 경고를 해제하는 방법뿐만 아니라 이전 설정에 따라 여러 개의 경고를 표시하거나 표시하지 않을 수 있습니다. – Alex

답변