Saving Screenshot captured from XCUIScreenshot Function

Viewed 2490

I am trying to use the function screenshot in XCTest to capture a screen, but I am unable to understand how to save this screenshot on to a simulator device or physical device

https://developer.apple.com/documentation/xctest/xcuiscreenshot

I am trying to Automate UI testing here and will need to capture a lot of screenshots for review.

2 Answers

Take a look on this. Download the source and import the needed stuffs into your code.

Its very simple to take screenshots while running UI tests. Just call saveScreenshot(path) method to take and save screenshots in desired path.

Related