5

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.

Charitha K
  • 51
  • 1
  • 2

2 Answers2

1

On the object XCUIScreenshot you have a property image using it you can retrieve and save the screenshot wherever you want.

To save the image you can see this topic : How to save picture to iPhone photo library?

Arnaud
  • 105
  • 6
1

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.

Confused
  • 3,846
  • 7
  • 45
  • 72