Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the screenshot file from Xcode UI Test?

Tags:

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. After couple of hours of research I can't find location of those screenshots.

like image 700
Robert Avatar asked May 17 '16 18:05

Robert


People also ask

What is UI testing in Xcode?

UI testing allows you to automate this procedure, so every time you update your code, Xcode will automatically test whether your app works correctly without you having to manually do it.

What is XCTest in iOS?

Overview. Use the XCTest framework to write unit tests for your Xcode projects that integrate seamlessly with Xcode's testing workflow. Tests assert that certain conditions are satisfied during code execution, and record test failures (with optional messages) if those conditions aren't satisfied.


1 Answers

Screenshots are stored inside your Derived Data folder. You can find this by going to Xcode, Window > Projects and click the little arrow next to your derived data path for the project.

From your project derived data folder (should be the name of your folder with a load of letters after it), go to Logs/Test.

Inside the Test folder will be test summary .plist files with UUIDs in their names (one per test run) and a folder called Attachments - the screenshots are in here.

If any of these folders aren't there, make sure you've run the tests first.

To work out which screenshot you want, you'll need to dig through the *_TestSummaries.plist file. Open it in Xcode and follow the test summary down to the SubActivity you're interested in. Some SubActivities don't have screenshots, and will have the HasScreenshotData key set to NO.

When you find a SubActivity with screenshot data, match the UUID for that SubActivity with the filename of the screenshot in the Attachments folder.

My screenshots were located at: /Users/{username}/Library/Developer/Xcode/DerivedData/{project_name}-tywebfjsswmghapfjfbzhuazjf/Logs/Test/Attachments.

In the .plist, I followed this path to find details of the screenshot data for an event: TestableSummaries > Item 0 > Tests > Item 0 > Subtests > Item 0 > Subtests > Item 0 > ActivitySummaries > Item 1 > SubActivities > Item 0.

like image 66
Oletha Avatar answered Sep 27 '22 21:09

Oletha