Where is the screenshot file from Xcode UI Test?

后端 未结 3 1541
遇见更好的自我
遇见更好的自我 2021-01-01 13:02

I\'m interested how to find the location of a screenshot which is created during UI Tests of my app. I would like to understand how Fastlane Snapshot grabs this screenshot.

3条回答
  •  离开以前
    2021-01-01 13:49

    To make screenshot you can call the next method

    func makeScreenShot() {
        let screenshot = XCUIScreen.main.screenshot()
        let fullScreenshotAttachment = XCTAttachment(screenshot: screenshot)
        fullScreenshotAttachment.lifetime = .keepAlways
    
        add(fullScreenshotAttachment)
    }
    

    You can find screenshots in Xcode -> Report navigator -> select your test

    Or go to

    DerivedData -> ProjectName... -> Logs -> Test -> find .xcresult -> Show Package Contents -> Attachments
    
    #For example
    /Users//Library/Developer/Xcode/DerivedData/-<...>/Logs/Test/Test--<...>.xcresult
    

    [Xcode run tests]

提交回复
热议问题