Skip to content

Commit fc4af9d

Browse files
davidleeeLee
andauthored
Create note 'Record, replay, and review: UI automation with Xcode' (#95)
Co-authored-by: Lee <[email protected]>
1 parent e0eca0b commit fc4af9d

2 files changed

Lines changed: 91 additions & 4 deletions

File tree

Sources/WWDCNotes/WWDCNotes.docc/WWDC25/WWDC25-344-Record-replay-and-review-UI-automation-with-Xcode.md

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,98 @@ Learn to record, run, and maintain XCUIAutomation tests in Xcode. Replay your XC
88
@CallToAction(url: "https://developer.apple.com/videos/play/wwdc2025/344", purpose: link, label: "Watch Video (24 min)")
99

1010
@Contributors {
11-
@GitHubUser(<replace this with your GitHub handle>)
11+
@GitHubUser(davidleee)
1212
}
1313
}
1414

15-
😱 "No Overview Available!"
15+
## Key Takeaways
16+
- 🤖 UI automation has three key phases: record, replay and review
17+
- 🦮 It is powered by Accessibility
18+
- ☁️ Can do on Xcode Cloud
1619

17-
Be the hero to change that by watching the video and providing notes! It's super easy:
18-
[Learn More…](https://wwdcnotes.com/documentation/wwdcnotes/contributing)
20+
## UI automation overview
21+
Inside Xcode there are two testing frameworks: Swift Testing & XCText.
22+
23+
When importing XCText, XCUIAutomation is automatically included.
24+
XCUIAutomation can interact with your app like a person does.
25+
26+
A complete app testing suite would be something like this:
27+
@Image(source: "WWDC25-344-complete-app-testing-suite")
28+
- Unit tests test your logic and models. With Swift Testing, you can test frameworks and Swift Packages that don't even have user interface.
29+
- UI automation tests validate your app's user experience, as well as integration with Apple harewares and the behaviors of common workflows.
30+
31+
### Benefits of UI automation
32+
- User experience
33+
- Accessibility
34+
- Localization
35+
- Hareware interaction
36+
- Launch performance
37+
38+
There are three key phrases to setup a UI automation:
39+
1. Record your interactions
40+
2. Replay in multiple configurations
41+
3. Review videos and results
42+
43+
> UI automation is supported on all apple platforms: iOS/iPadOS, macOS, watchOS, tvOS, visionOS(Designed for iPad).
44+
45+
### Sum up for what UI automation can do
46+
- Interacts with your app like a person would
47+
- Runs independently from your app
48+
- Instructs the operating system what actions to perform
49+
- Actions include launching your app, interacting with it, and setting system state
50+
51+
> Accessibility powers UI automation. Having a great experience of Accessibility means you will get a great UI automation experience too.
52+
53+
## Prepare your app for automation
54+
> Your app can be automated with no code changes. The steps covered in this section is not required, but they can lead to better and higher quality of results.
55+
56+
1. Add accessibility identifiers
57+
- Best way to identify an element in your app for automation
58+
- Add identifiers for elements with localized strings or dynamic content
59+
- Good identifiers are:
60+
- Unique
61+
- Descriptive
62+
- Static
63+
64+
In SwiftUI, this is done by adding a view modifier `.accessibilityIdentifier`. In UIKit, set the `accessibilityIdentifier` property of an accessibility element.
65+
> Most UIView like Controls, Texts, and Images are accessibility elements by default.
66+
67+
Accessibility property exposure:
68+
| Property | VoiceOver | UI Automation |
69+
|-------------------------|-----------|---------------|
70+
| accessibilityLabel |||
71+
| accessibilityTraits |||
72+
| accessibilityValue |||
73+
| accessibilityIdentifier |||
74+
75+
2. Review your app's accessibility
76+
Xcode ships with an app call Accessibility Inspector, which lets you find, diagnose and fix accessibility issues.
77+
78+
3. Add a new UI testing target
79+
80+
## Record your interactions
81+
When open the UI test source file for the first time, a popover will appear telling you how to start a UI recording.
82+
Or you can tap the button on the side bar, then Xcode will automatically build and relaunch your app in the simulator.
83+
84+
Next, as you interact with your app, the code representing your interactions will be recorded in the source editor.
85+
86+
After recording, these steps may help you get the automation you wanted:
87+
- Review UI queries
88+
- Prefer accessibility identifiers over localized string
89+
- Keep queries as concise as possible
90+
- Prefer generic queries for dynamic content
91+
92+
- Add validations
93+
- Explore other automation APIs
94+
95+
## Replay in multiple configurations
96+
### Test plan configuration
97+
- Include or exclude individual tests
98+
- Set system settings for where and how tests will run
99+
- Manage timeouts, repetitions on failure, and execution order
100+
- Associated with a scheme and build settings
101+
102+
You can use Xcode Cloud to run your UI tests.
103+
104+
## Review videos and results
105+
Double click on the failure of the test report and you can check the video recorded when the test failed.
Loading

0 commit comments

Comments
 (0)