2017-01-24 4 views
2

XCUITests에서 UIApplication 바로 가기를 테스트 할 수있는 방법이 있습니까?XCUITest 응용 프로그램 바로 가기

시뮬레이터에서 3d 바로 가기를 테스트하려면 강제 터치로 트랙 패드가 필요하지만 내 바로 가기를 테스트하는 테스트를 작성할 수 있는지 궁금합니다.

답변

-1

예! 하지만 비공개 API를 노출해야합니다. Facebook's WebDriverAgent here에서 XCUIElement 헤더를 내 보냈습니다.

또는, 즉 당신이 필요로하는 유일한 있다면, 단지 람에 노출 :

@interface XCUIElement (Private) 
    - (void)forcePress; 
@end 

그리고 그 발판에 가서 당신의 아이콘 요소 see my answer here을 받고하여 아이콘을 눌러 강제로.

class Springboard { 
    // this is another private method you'll need to expose (see linked other answer) 
    static let springboard = XCUIApplication(privateWithPath: nil, bundleID: "com.apple.springboard") 


    /// Open the 3d touch menu 
    class func open3dTouchMenu() { 
     XCUIApplication().terminate() // this may or may not be necessary depending on your desired function/app state 

     // Resolve the query for the springboard rather than launching it 
     springboard.resolve() 

     // Force delete the app from the springboard 
     let icon = springboard.icons["MyAppName"] 
     if icon.exists { 
      icon.forcePress() 
      // do something with the menu that comes up 
     } 
    } 
} 

* 아직 테스트하지 않았습니다.