PlaybookAccessibilitySnapshot
PlaybookAccessibilitySnapshot
is an extension to Playbook that uses AccessibilitySnapshot to produce snapshots with accessibility information such as activation points and labels.
Usage
AccessibilitySnapshot
final class AccessibilitySnapshotTests: XCTestCase {
func testTakeAccessibilitySnapshot() throws {
let directory = ProcessInfo.processInfo.environment["SNAPSHOT_DIR"]!
try Playbook.default.run(
AccessibilitySnapshot(
directory: URL(fileURLWithPath: directory),
clean: true,
format: .png,
keyWindow: UIApplication.shared.windows.first { $0.isKeyWindow },
devices: [.iPhone11Pro(.portrait)]
)
)
}
}
Sample | Before | After |
---|---|---|
Integration with Third-party Tools
The generated snapshot images with accessibility information can be used for more advanced visual regression testing by using a variety of third party tools.
percy
Requirements
- Swift 5.3+
- Xcode 12.2+
- iOS 12.0+
Installation
CocoaPods
Add the following to your Podfile
:
target 'YourPlaybook' do
pod 'Playbook'
target 'YourPlaybookTests' do
inherit! :search_paths
pod 'PlaybookAccessibilitySnapshot'
end
end
Swift Package Manager
Select Xcode menu File > Swift Packages > Add Package Dependency...
and enter repository URL with GUI.
Repository: https://github.com/playbook-ui/accessibility-snapshot-ios.git
Development
- Run
make proj
at the root of this repository. - Open
Example/Example.xcworkspace
via Xcode. - Develop a PlaybookAccessibilitySnapshot installed as a development pods.
License
Playbook is released under the Apache 2.0 License.