iosswiftunit-testingxcode-ui-testingswift-snapshot-testing

Capture screen recording with UITesting in Swift


Is there any tool or service for capturing screen-recording or screenshot with UITesting?

I do not want snapshot testing from https://github.com/pointfreeco/swift-snapshot-testing.

Thank you,


Solution

  • You can configure it in the scheme

    enter image description here

    First you need to remove checkmark in "Delete when each test succeeds" remove checkmark in "Delete when each test succeeds" in attachments section too

    Then you can find the screenshots in test logs

    enter image description here

    You can also take screenshots of different components using screenshot()

    let screenShot = emailTextField.screenshot()
    let emailScreenAttachment = XCTAttachment(screenshot: screenShot)
    emailScreenAttachment.name = "screnshot of email textField"
    emailScreenAttachment.lifetime = .keepAlways
    add(emailScreenAttachment)