[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E6V7D20BCPPCRTV5W6H3KF":3,"skill-same:01M6E6V7D20BCPPCRTV5W6H3KF":98},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":40,"publishedAt":61,"linkOnly":62,"markdownContent":63,"markdownBody":64,"frontMatter":65,"refName":69,"commitSha":70,"skillDirectory":71,"forksCount":72,"repositoryHtmlUrl":73,"repositoryHomepageUrl":74,"ownerHtmlUrl":75,"ownerBlogUrl":6,"ownerDescription":76,"updatedAt":77,"install":78,"resources":91},"01M6E6V7D20BCPPCRTV5W6H3KF","axiom-ui-testing",null,"Use when writing UI tests, recording interactions, tests have race conditions, timing dependencies, inconsistent pass\u002Ffail behavior, or XCTest UI tests are flaky - covers Recording UI Automation (WWDC 2025), condition-based waiting, network conditioning, multi-factor testing, crash debugging, and accessibility-first testing patterns","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-ui-testing\u002FSKILL.md",[18,23,26,29,34,37],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":30,"categoryName":31,"taxonomyType":32,"taxonomyTypeDesc":33},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",{"categoryNo":35,"categoryName":36,"taxonomyType":32,"taxonomyTypeDesc":33},"01JBSEEDCAT000000000000032","设计师",{"categoryNo":38,"categoryName":39,"taxonomyType":32,"taxonomyTypeDesc":33},"01JBSEEDCAT000000000000036","内容创作者",[41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60],"axiom ui testing","ui","ui testing","testing","behavior","timing","condition","factor","tests","dependencies","patterns","use","first","testing patterns","multi-factor","network","debugging","accessibility","automation","writing","2026-11-10 10:12:30",false,"---\nname: axiom-ui-testing\ndescription: Use when writing UI tests, recording interactions, tests have race conditions, timing dependencies, inconsistent pass\u002Ffail behavior, or XCTest UI tests are flaky - covers Recording UI Automation (WWDC 2025), condition-based waiting, network conditioning, multi-factor testing, crash debugging, and accessibility-first testing patterns\nlicense: MIT\nmetadata:\n  version: \"2.1.0\"\n  last-updated: \"WWDC 2025 (Updated with production debugging patterns)\"\n---\n\n# UI Testing\n\n## Overview\n\nWait for conditions, not arbitrary timeouts. **Core principle** Flaky tests come from guessing how long operations take. Condition-based waiting eliminates race conditions.\n\n**NEW in WWDC 2025**: Recording UI Automation allows you to record interactions, replay across devices\u002Flanguages, and review video recordings of test runs.\n\n## Example Prompts\n\nThese are real questions developers ask that this skill is designed to answer:\n\n#### 1. \"My UI tests pass locally on my Mac but fail in CI. How do I make them more reliable?\"\n→ The skill shows condition-based waiting patterns that work across devices\u002Fspeeds, eliminating CI timing differences\n\n#### 2. \"My tests use sleep(2) and sleep(5) but they're still flaky. How do I replace arbitrary timeouts with real conditions?\"\n→ The skill demonstrates waitForExistence, XCTestExpectation, and polling patterns for data loads, network requests, and animations\n\n#### 3. \"I just recorded a test using Xcode 26's Recording UI Automation. How do I review the video and debug failures?\"\n→ The skill covers Video Debugging workflows to analyze recordings and find the exact step where tests fail\n\n#### 4. \"My test is failing on iPad but passing on iPhone. How do I write tests that work across all device sizes?\"\n→ The skill explains multi-factor testing strategies and device-independent predicates for robust cross-device testing\n\n#### 5. \"I want to write tests that are not flaky. What are the critical patterns I need to know?\"\n→ The skill provides condition-based waiting templates, accessibility-first patterns, and the decision tree for reliable test architecture\n\n---\n\n## Red Flags — Test Reliability Issues\n\nIf you see ANY of these, suspect timing issues:\n- Tests pass locally, fail in CI (timing differences)\n- Tests sometimes pass, sometimes fail (race conditions)\n- Tests use `sleep()` or `Thread.sleep()` (arbitrary delays)\n- Tests fail with \"UI element not found\" then pass on retry\n- Long test runs (waiting for worst-case scenarios)\n\n## Quick Decision Tree\n\n```\nTest failing?\n├─ Element not found?\n│  └─ Use waitForExistence(timeout:) not sleep()\n├─ Passes locally, fails CI?\n│  └─ Replace sleep() with condition polling\n├─ Animation causing issues?\n│  └─ Wait for animation completion, don't disable\n└─ Network request timing?\n   └─ Use XCTestExpectation or waitForExistence\n```\n\n## Core Pattern: Condition-Based Waiting\n\n**❌ WRONG (Arbitrary Timeout)**:\n```swift\nfunc testButtonAppears() {\n    app.buttons[\"Login\"].tap()\n    sleep(2)  \u002F\u002F ❌ Guessing it takes 2 seconds\n    XCTAssertTrue(app.buttons[\"Dashboard\"].exists)\n}\n```\n\n**✅ CORRECT (Wait for Condition)**:\n```swift\nfunc testButtonAppears() {\n    app.buttons[\"Login\"].tap()\n    let dashboard = app.buttons[\"Dashboard\"]\n    XCTAssertTrue(dashboard.waitForExistence(timeout: 5))\n}\n```\n\n## Common UI Testing Patterns\n\n### Pattern 1: Waiting for Elements\n\n```swift\n\u002F\u002F Wait for element to appear\nfunc waitForElement(_ element: XCUIElement, timeout: TimeInterval = 5) -> Bool {\n    return element.waitForExistence(timeout: timeout)\n}\n\n\u002F\u002F Usage\nXCTAssertTrue(waitForElement(app.buttons[\"Submit\"]))\n```\n\n### Pattern 2: Waiting for Element to Disappear\n\n```swift\nfunc waitForElementToDisappear(_ element: XCUIElement, timeout: TimeInterval = 5) -> Bool {\n    let predicate = NSPredicate(format: \"exists == false\")\n    let expectation = XCTNSPredicateExpectation(predicate: predicate, object: element)\n    let result = XCTWaiter().wait(for: [expectation], timeout: timeout)\n    return result == .completed\n}\n\n\u002F\u002F Usage\nXCTAssertTrue(waitForElementToDisappear(app.activityIndicators[\"Loading\"]))\n```\n\n### Pattern 3: Waiting for Specific State\n\n```swift\nfunc waitForButton(_ button: XCUIElement, toBeEnabled enabled: Bool, timeout: TimeInterval = 5) -> Bool {\n    let predicate = NSPredicate(format: \"isEnabled == %@\", NSNumber(value: enabled))\n    let expectation = XCTNSPredicateExpectation(predicate: predicate, object: button)\n    let result = XCTWaiter().wait(for: [expectation], timeout: timeout)\n    return result == .completed\n}\n\n\u002F\u002F Usage\nlet submitButton = app.buttons[\"Submit\"]\nXCTAssertTrue(waitForButton(submitButton, toBeEnabled: true))\nsubmitButton.tap()\n```\n\n### Pattern 4: Accessibility Identifiers\n\n**Set in app**:\n```swift\nButton(\"Submit\") {\n    \u002F\u002F action\n}\n.accessibilityIdentifier(\"submitButton\")\n```\n\n**Use in tests**:\n```swift\nfunc testSubmitButton() {\n    let submitButton = app.buttons[\"submitButton\"]  \u002F\u002F Uses identifier, not label\n    XCTAssertTrue(submitButton.waitForExistence(timeout: 5))\n    submitButton.tap()\n}\n```\n\n**Why**: Accessibility identifiers don't change with localization, remain stable across UI updates.\n\n### Pattern 5: Network Request Delays\n\n```swift\nfunc testDataLoads() {\n    app.buttons[\"Refresh\"].tap()\n\n    \u002F\u002F Wait for loading indicator to disappear\n    let loadingIndicator = app.activityIndicators[\"Loading\"]\n    XCTAssertTrue(waitForElementToDisappear(loadingIndicator, timeout: 10))\n\n    \u002F\u002F Now verify data loaded\n    XCTAssertTrue(app.cells.count > 0)\n}\n```\n\n### Pattern 6: Animation Handling\n\n```swift\nfunc testAnimatedTransition() {\n    app.buttons[\"Next\"].tap()\n\n    \u002F\u002F Wait for destination view to appear\n    let destinationView = app.otherElements[\"DestinationView\"]\n    XCTAssertTrue(destinationView.waitForExistence(timeout: 2))\n\n    \u002F\u002F Optional: Wait a bit more for animation to settle\n    \u002F\u002F Only if absolutely necessary\n    RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.3))\n}\n```\n\n## Testing Checklist\n\n### Before Writing Tests\n- [ ] Use accessibility identifiers for all interactive elements\n- [ ] Avoid hardcoded labels (use identifiers instead)\n- [ ] Plan for network delays and animations\n- [ ] Choose appropriate timeouts (2s UI, 10s network)\n\n### When Writing Tests\n- [ ] Use `waitForExistence()` not `sleep()`\n- [ ] Use predicates for complex conditions\n- [ ] Test both success and failure paths\n- [ ] Make tests independent (can run in any order)\n\n### After Writing Tests\n- [ ] Run tests 10 times locally (catch flakiness)\n- [ ] Run tests on slowest supported device\n- [ ] Run tests in CI environment\n- [ ] Check test duration (if >30s per test, optimize)\n\n## Xcode UI Testing Tips\n\n### Launch Arguments for Testing\n\n```swift\nfunc testExample() {\n    let app = XCUIApplication()\n    app.launchArguments = [\"UI-Testing\"]\n    app.launch()\n}\n```\n\nIn app code:\n```swift\nif ProcessInfo.processInfo.arguments.contains(\"UI-Testing\") {\n    \u002F\u002F Use mock data, skip onboarding, etc.\n}\n```\n\n### Faster Test Execution\n\n```swift\noverride func setUpWithError() throws {\n    continueAfterFailure = false  \u002F\u002F Stop on first failure\n}\n```\n\n### Debugging Failing Tests\n\n```swift\nfunc testExample() {\n    \u002F\u002F Take screenshot on failure\n    addUIInterruptionMonitor(withDescription: \"Alert\") { alert in\n        alert.buttons[\"OK\"].tap()\n        return true\n    }\n\n    \u002F\u002F Print element hierarchy\n    print(app.debugDescription)\n}\n```\n\n## Common Mistakes\n\n### ❌ Using sleep() for Everything\n```swift\nsleep(5)  \u002F\u002F ❌ Wastes time if operation completes in 1s\n```\n\n### ❌ Not Handling Animations\n```swift\napp.buttons[\"Next\"].tap()\nXCTAssertTrue(app.buttons[\"Back\"].exists)  \u002F\u002F ❌ May fail during animation\n```\n\n### ❌ Hardcoded Text Labels\n```swift\napp.buttons[\"Submit\"].tap()  \u002F\u002F ❌ Breaks with localization\n```\n\n### ❌ Tests Depend on Each Other\n```swift\n\u002F\u002F ❌ Test 2 assumes Test 1 ran first\nfunc test1_Login() { \u002F* ... *\u002F }\nfunc test2_ViewDashboard() { \u002F* assumes logged in *\u002F }\n```\n\n### ❌ No Timeout Strategy\n```swift\nelement.waitForExistence(timeout: 100)  \u002F\u002F ❌ Too long\nelement.waitForExistence(timeout: 0.1)  \u002F\u002F ❌ Too short\n```\n\n**Use appropriate timeouts**:\n- UI animations: 2-3 seconds\n- Network requests: 10 seconds\n- Complex operations: 30 seconds max\n\n## Real-World Impact\n\n**Before** (using sleep()):\n- Test suite: 15 minutes (waiting for worst-case)\n- Flaky tests: 20% failure rate\n- CI failures: 50% require retry\n\n**After** (condition-based waiting):\n- Test suite: 5 minutes (waits only as needed)\n- Flaky tests: \u003C2% failure rate\n- CI failures: \u003C5% require retry\n\n**Key insight** Tests finish faster AND are more reliable when waiting for actual conditions instead of guessing times.\n\n---\n\n## Recording UI Automation\n\n### Overview\n\n**NEW in Xcode 26**: Record, replay, and review UI automation tests with video recordings.\n\n**Three Phases**:\n1. **Record** — Capture interactions (taps, swipes, hardware button presses) as Swift code\n2. **Replay** — Run across multiple devices, languages, regions, orientations\n3. **Review** — Watch video recordings, analyze failures, view UI element overlays\n\n**Supported Platforms**: iOS, iPadOS, macOS, watchOS, tvOS, axiom-visionOS (Designed for iPad)\n\n### How UI Automation Works\n\n**Key Principles**:\n- UI automation interacts with your app **as a person does** using gestures and hardware events\n- Runs **completely independently** from your app (app models\u002Fdata not directly accessible)\n- Uses **accessibility framework** as underlying technology\n- Tells OS which gestures to perform, then waits for completion **synchronously** one at a time\n\n**Actions include**:\n- Launching your app\n- Interacting with buttons and navigation\n- Setting system state (Dark Mode, axiom-localization, etc.)\n- Setting simulated location\n\n### Accessibility is the Foundation\n\n**Critical Understanding**: Accessibility provides information directly to UI automation.\n\nWhat accessibility sees:\n- Element types (button, text, image, etc.)\n- Labels (visible text)\n- Values (current state for checkboxes, etc.)\n- Frames (element positions)\n- **Identifiers** (accessibility identifiers — NOT localized)\n\n**Best Practice**: Great accessibility experience = great UI automation experience.\n\n### Preparing Your App for Recording\n\n#### Step 1: Add Accessibility Identifiers\n\n**SwiftUI**:\n```swift\nButton(\"Submit\") {\n    \u002F\u002F action\n}\n.accessibilityIdentifier(\"submitButton\")\n\n\u002F\u002F Make identifiers specific to instance\nList(landmarks) { landmark in\n    LandmarkRow(landmark)\n        .accessibilityIdentifier(\"landmark-\\(landmark.id)\")\n}\n```\n\n**UIKit**:\n```swift\nlet button = UIButton()\nbutton.accessibilityIdentifier = \"submitButton\"\n\n\u002F\u002F Use index for table cells\ncell.accessibilityIdentifier = \"cell-\\(indexPath.row)\"\n```\n\n**Good identifiers are**:\n- ✅ Unique within entire app\n- ✅ Descriptive of element contents\n- ✅ Static (don't react to content changes)\n- ✅ Not localized (same across languages)\n\n**Why identifiers matter**:\n- Titles\u002Fdescriptions may change, identifiers remain stable\n- Work across localized strings\n- Uniquely identify elements with dynamic content\n\n**Pro Tip**: Use Xcode coding assistant to add identifiers:\n```\nPrompt: \"Add accessibility identifiers to the relevant parts of this view\"\n```\n\n#### Step 2: Review Accessibility with Accessibility Inspector\n\n**Launch Accessibility Inspector**:\n- Xcode menu → Open Developer Tool → Accessibility Inspector\n- Or: Launch from Spotlight\n\n**Features**:\n1. **Element Inspector** — List accessibility values for any view\n2. **Property details** — Click property name for documentation\n3. **Platform support** — Works on all Apple platforms\n\n**What to check**:\n- Elements have labels\n- Interactive elements have types (button, not just text)\n- Values set for stateful elements (checkboxes, toggles)\n- Identifiers set for elements with dynamic\u002Flocalized content\n\n**Sample Code Reference**: [Delivering an exceptional accessibility experience](https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Faccessibility\u002Fdelivering_an_exceptional_accessibility_experience)\n\n#### Step 3: Add UI Testing Target\n\n1. Open project settings in Xcode\n2. Click \"+\" below targets list\n3. Select **UI Testing Bundle**\n4. Click Finish\n\n**Result**: New UI test folder with template tests added to project.\n\n### Recording Interactions\n\n#### Starting a Recording (Xcode 26)\n\n1. Open UI test source file\n2. **Popover appears** explaining how to start recording (first time only)\n3. Click **\"Start Recording\"** button in editor gutter\n4. Xcode builds and launches app in Simulator\u002Fdevice\n\n**During Recording**:\n- Interact with app normally (taps, swipes, text entry, etc.)\n- Code representing interactions appears in source editor in real-time\n- Recording updates as you type (e.g., text field entries)\n\n**Stopping Recording**:\n- Click **\"Stop Run\"** button in Xcode\n\n#### Example Recording Session\n\n```swift\nfunc testCreateAustralianCollection() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Tap \"Collections\" tab (recorded automatically)\n    app.tabBars.buttons[\"Collections\"].tap()\n\n    \u002F\u002F Tap \"+\" to add new collection\n    app.navigationBars.buttons[\"Add\"].tap()\n\n    \u002F\u002F Tap \"Edit\" button\n    app.buttons[\"Edit\"].tap()\n\n    \u002F\u002F Type collection name\n    app.textFields.firstMatch.tap()\n    app.textFields.firstMatch.typeText(\"Max's Australian Adventure\")\n\n    \u002F\u002F Tap \"Edit Landmarks\"\n    app.buttons[\"Edit Landmarks\"].tap()\n\n    \u002F\u002F Add landmarks\n    app.tables.cells.containing(.staticText, identifier:\"Great Barrier Reef\").buttons[\"Add\"].tap()\n    app.tables.cells.containing(.staticText, identifier:\"Uluru\").buttons[\"Add\"].tap()\n\n    \u002F\u002F Tap checkmark to save\n    app.navigationBars.buttons[\"Done\"].tap()\n}\n```\n\n#### Reviewing Recorded Code\n\nAfter recording, **review and adjust queries**:\n\n**Multiple Options**: Each line has dropdown showing alternative ways to address element.\n\n**Selection Recommendations**:\n1. **For localized strings** (text, button labels): Choose accessibility identifier if available\n2. **For deeply nested views**: Choose shortest query (stays resilient as app changes)\n3. **For dynamic content** (timestamps, temperature): Use generic query or identifier\n\n**Example**:\n```swift\n\u002F\u002F Recorded options for text field:\napp.textFields[\"Collection Name\"]              \u002F\u002F ❌ Breaks if label localizes\napp.textFields[\"collectionNameField\"]          \u002F\u002F ✅ Uses identifier\napp.textFields.element(boundBy: 0)             \u002F\u002F ✅ Position-based\napp.textFields.firstMatch                      \u002F\u002F ✅ Generic, shortest\n```\n\n**Choose shortest, most stable query** for your needs.\n\n### Adding Validations\n\nAfter recording, **add assertions** to verify expected behavior:\n\n#### Wait for Existence\n\n```swift\n\u002F\u002F Validate collection created\nlet collection = app.buttons[\"Max's Australian Adventure\"]\nXCTAssertTrue(collection.waitForExistence(timeout: 5))\n```\n\n#### Wait for Property Changes\n\n```swift\n\u002F\u002F Wait for button to become enabled\nlet submitButton = app.buttons[\"Submit\"]\nXCTAssertTrue(submitButton.wait(for: .enabled, toEqual: true, timeout: 5))\n```\n\n#### Combine with XCTAssert\n\n```swift\n\u002F\u002F Fail test if element doesn't appear\nlet landmark = app.staticTexts[\"Great Barrier Reef\"]\nXCTAssertTrue(landmark.waitForExistence(timeout: 5), \"Landmark should appear in collection\")\n```\n\n### Advanced Automation APIs\n\n#### Setup Device State\n\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Set device orientation\n    XCUIDevice.shared.orientation = .landscapeLeft\n\n    \u002F\u002F Set appearance mode\n    app.launchArguments += [\"-UIUserInterfaceStyle\", \"dark\"]\n\n    \u002F\u002F Simulate location\n    let location = XCUILocation(location: CLLocation(latitude: 37.7749, longitude: -122.4194))\n    app.launchArguments += [\"-SimulatedLocation\", location.description]\n\n    app.launch()\n}\n```\n\n#### Launch Arguments & Environment\n\n```swift\nfunc testWithMockData() {\n    let app = XCUIApplication()\n\n    \u002F\u002F Pass arguments to app\n    app.launchArguments = [\"-UI-Testing\", \"-UseMockData\"]\n\n    \u002F\u002F Set environment variables\n    app.launchEnvironment = [\"API_URL\": \"https:\u002F\u002Fmock.api.com\"]\n\n    app.launch()\n}\n```\n\nIn app code:\n```swift\nif ProcessInfo.processInfo.arguments.contains(\"-UI-Testing\") {\n    \u002F\u002F Use mock data, skip onboarding\n}\n```\n\n#### Custom URL Schemes\n\n```swift\n\u002F\u002F Open app to specific URL\nlet app = XCUIApplication()\napp.open(URL(string: \"myapp:\u002F\u002Flandmark\u002F123\")!)\n\n\u002F\u002F Open URL with system default app (global version)\nXCUIApplication.open(URL(string: \"https:\u002F\u002Fexample.com\")!)\n```\n\n#### Accessibility Audits in Tests\n\n```swift\nfunc testAccessibility() throws {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Perform accessibility audit\n    try app.performAccessibilityAudit()\n}\n```\n\n**Reference**: [Perform accessibility audits for your app — WWDC23](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2023\u002F10035\u002F)\n\n### Test Plans for Multiple Configurations\n\n**Test Plans** let you:\n- Include\u002Fexclude individual tests\n- Set system settings (language, region, appearance)\n- Configure test properties (timeouts, repetitions, parallelization)\n- Associate with schemes for specific build settings\n\n#### Creating Test Plan\n\n1. Create new or use existing test plan\n2. Add\u002Fremove tests on first screen\n3. Switch to **Configurations** tab\n\n#### Adding Multiple Languages\n\n```\nConfigurations:\n├─ English\n├─ German (longer strings)\n├─ Arabic (right-to-left)\n└─ Hebrew (right-to-left)\n```\n\n**Each locale** = separate configuration in test plan.\n\n**Settings**:\n- Focused for specific locale\n- Shared across all configurations\n\n#### Video & Screenshot Capture\n\n**In Configurations tab**:\n- **Capture screenshots**: On\u002FOff\n- **Capture video**: On\u002FOff\n- **Keep media**: \"Only failures\" or \"On, and keep all\"\n\n**Defaults**: Videos\u002Fscreenshots kept only for failing runs (for review).\n\n**\"On, and keep all\" use cases**:\n- Documentation\n- Tutorials\n- Marketing materials\n\n**Reference**: [Author fast and reliable tests for Xcode Cloud — WWDC22](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2022\u002F110371\u002F)\n\n### Replaying Tests in Xcode Cloud\n\n**Xcode Cloud** = built-in service for:\n- Building app\n- Running tests\n- Uploading to App Store\n- All in cloud without using team devices\n\n**Workflow configuration**:\n- Same test plan used locally\n- Runs on multiple devices and configurations\n- Videos\u002Fresults available in App Store Connect\n\n**Viewing Results**:\n- Xcode: Xcode Cloud section\n- App Store Connect: Xcode Cloud section\n- See build info, logs, failure descriptions, video recordings\n\n**Team Access**: Entire team can see run history and download results\u002Fvideos.\n\n**Reference**: [Create practical workflows in Xcode Cloud — WWDC23](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2023\u002F10269\u002F)\n\n### Reviewing Test Results with Videos\n\n#### Accessing Test Report\n\n1. Click **Test** button in Xcode\n2. Double-click failing run to see video + description\n\n**Features**:\n- **Runs dropdown** — Switch between video recordings of different configurations (languages, devices)\n- **Save video** — Secondary click → Save\n- **Play\u002Fpause** — Video playback with UI interaction overlays\n- **Timeline dots** — UI interactions shown as dots on timeline\n- **Jump to failure** — Click failure diamond on timeline\n\n#### UI Element Overlay at Failure\n\n**At moment of failure**:\n- Click timeline failure point\n- **Overlay shows all UI elements** present on screen\n- Click any element to see code recommendations for addressing it\n- **Show All** — See alternative examples\n\n**Workflow**:\n1. Identify what was actually present (vs what test expected)\n2. Click element to get query code\n3. Secondary click → Copy code\n4. **View Source** → Go directly to test\n5. Paste corrected code\n\n**Example**:\n```swift\n\u002F\u002F Test expected:\nlet button = app.buttons[\"Max's Australian Adventure\"]\n\n\u002F\u002F But overlay shows it's actually text, not button:\nlet text = app.staticTexts[\"Max's Australian Adventure\"] \u002F\u002F ✅ Correct\n```\n\n#### Running Test in Different Language\n\nClick test diamond → Select configuration (e.g., Arabic) → Watch automation run in right-to-left layout.\n\n**Validates**: Same automation works across languages\u002Flayouts.\n\n**Reference**: [Fix failures faster with Xcode test reports — WWDC23](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2023\u002F10175\u002F)\n\n### Recording UI Automation Checklist\n\n#### Before Recording\n- [ ] Add accessibility identifiers to interactive elements\n- [ ] Review app with Accessibility Inspector\n- [ ] Add UI Testing Bundle target to project\n- [ ] Plan workflow to record (user journey)\n\n#### During Recording\n- [ ] Interact naturally with app\n- [ ] Record complete user journeys (not individual taps)\n- [ ] Check code generates as you interact\n- [ ] Stop recording when workflow complete\n\n#### After Recording\n- [ ] Review recorded code options (dropdown on each line)\n- [ ] Choose stable queries (identifiers > labels)\n- [ ] Add validations (waitForExistence, XCTAssert)\n- [ ] Add setup code (device state, launch arguments)\n- [ ] Run test to verify it passes\n\n#### Test Plan Configuration\n- [ ] Create\u002Fupdate test plan\n- [ ] Add multiple language configurations\n- [ ] Include right-to-left languages (Arabic, Hebrew)\n- [ ] Configure video\u002Fscreenshot capture settings\n- [ ] Set appropriate timeouts for network tests\n\n#### Running & Reviewing\n- [ ] Run test locally across configurations\n- [ ] Review video recordings for failures\n- [ ] Use UI element overlay to debug failures\n- [ ] Run in Xcode Cloud for team visibility\n- [ ] Download and share videos if needed\n\n## Network Conditioning in Tests\n\n### Overview\n\nUI tests can pass on fast networks but fail on 3G\u002FLTE. **Network Link Conditioner** simulates real-world network conditions to catch timing-sensitive crashes.\n\n**Critical scenarios**:\n- ❌ iPad Pro over Wi-Fi (fast) → pass\n- ❌ iPad Pro over 3G (slow) → crash\n- ✅ Test both to catch device-specific failures\n\n### Setup Network Link Conditioner\n\n**Install Network Link Conditioner**:\n1. Download from [Apple's Additional Tools for Xcode](https:\u002F\u002Fdeveloper.apple.com\u002Fdownload\u002Fall\u002F)\n2. Search: \"Network Link Conditioner\"\n3. Install: `sudo open Network\\ Link\\ Conditioner.pkg`\n\n**Verify Installation**:\n```bash\n# Check if installed\nls ~\u002FLibrary\u002FApplication\\ Support\u002FNetwork\\ Link\\ Conditioner\u002F\n```\n\n**Enable in Tests**:\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Launch with network conditioning argument\n    app.launchArguments = [\"-com.apple.CoreSimulator.CoreSimulatorService\", \"-networkShaping\"]\n    app.launch()\n}\n```\n\n### Common Network Profiles\n\n**3G Profile** (most failures occur here):\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Simulate 3G (type in launch arguments)\n    app.launchEnvironment = [\n        \"SIMULATOR_UDID\": ProcessInfo.processInfo.environment[\"SIMULATOR_UDID\"] ?? \"\",\n        \"NETWORK_PROFILE\": \"3G\"\n    ]\n    app.launch()\n}\n```\n\n**Manual Network Conditioning** (macOS System Preferences):\n1. Open System Preferences → Network\n2. Click \"Network Link Conditioner\" (installed above)\n3. Select profile: 3G, LTE, WiFi\n4. Click \"Start\"\n5. Run tests (they'll use throttled network)\n\n### Real-World Example: Photo Upload with Network Throttling\n\n**❌ Without Network Conditioning**:\n```swift\nfunc testPhotoUpload() {\n    app.buttons[\"Upload Photo\"].tap()\n\n    \u002F\u002F Passes locally (fast network)\n    XCTAssertTrue(app.staticTexts[\"Upload complete\"].waitForExistence(timeout: 5))\n}\n\u002F\u002F ✅ Passes locally, ❌ FAILS on 3G with timeout\n```\n\n**✅ With Network Conditioning**:\n```swift\nfunc testPhotoUploadOn3G() {\n    let app = XCUIApplication()\n    \u002F\u002F Network Link Conditioner running (3G profile)\n    app.launch()\n\n    app.buttons[\"Upload Photo\"].tap()\n\n    \u002F\u002F Increase timeout for 3G\n    XCTAssertTrue(app.staticTexts[\"Upload complete\"].waitForExistence(timeout: 30))\n\n    \u002F\u002F Verify no crash occurred\n    XCTAssertFalse(app.alerts.element.exists, \"App should not crash on 3G\")\n}\n```\n\n**Key differences**:\n- Longer timeout (30s instead of 5s)\n- Check for crashes\n- Run on slowest expected network\n\n---\n\n## Multi-Factor Testing: Device Size + Network Speed\n\n### The Problem\n\nTests can pass on device A but fail on device B due to layout differences + network delays. **Multi-factor testing** catches these combinations.\n\n**Common failure patterns**:\n- ✅ iPhone 14 Pro (compact, fast network)\n- ❌ iPad Pro 12.9 (large, 3G network) → crashes\n- ✅ iPhone 15 (compact, LTE)\n- ❌ iPhone 12 (older GPU, 3G) → timeout\n\n### Test Plan Configuration for Multiple Devices\n\n**Create Test Plan in Xcode**:\n1. File → New → Test Plan\n2. Select tests to include\n3. Click \"Configurations\" tab\n4. Add configurations for each device\u002Fnetwork combo\n\n**Example Configuration Matrix**:\n```\nConfigurations:\n├─ iPhone 14 Pro + LTE\n├─ iPhone 14 Pro + 3G\n├─ iPad Pro 12.9 + LTE\n├─ iPad Pro 12.9 + 3G  (⚠️ Most failures here)\n└─ iPhone 12 + 3G      (⚠️ Older device)\n```\n\n**In Test Plan UI**:\n- Device: iPhone 14 Pro \u002F iPad Pro 12.9\n- OS Version: Latest\n- Locale: English\n- Network Profile: LTE \u002F 3G\n\n### Programmatic Device-Specific Testing\n\n```swift\nimport XCTest\n\nfinal class MultiFactorUITests: XCTestCase {\n    var deviceModel: String { UIDevice.current.model }\n\n    override func setUpWithError() throws {\n        let app = XCUIApplication()\n        app.launch()\n\n        \u002F\u002F Adjust timeouts based on device\n        switch deviceModel {\n        case \"iPad\" where UIScreen.main.bounds.width > 1000:\n            \u002F\u002F iPad Pro - larger layout, slower rendering\n            app.launchEnvironment[\"TEST_TIMEOUT\"] = \"30\"\n        case \"iPhone\":\n            \u002F\u002F iPhone - compact, standard timeout\n            app.launchEnvironment[\"TEST_TIMEOUT\"] = \"10\"\n        default:\n            app.launchEnvironment[\"TEST_TIMEOUT\"] = \"15\"\n        }\n    }\n\n    func testListLoadingAcrossDevices() {\n        let app = XCUIApplication()\n        let timeout = Double(app.launchEnvironment[\"TEST_TIMEOUT\"] ?? \"10\") ?? 10\n\n        app.buttons[\"Refresh\"].tap()\n\n        \u002F\u002F Wait for list to load (timeout varies by device)\n        XCTAssertTrue(\n            app.tables.cells.count > 0,\n            \"List should load on \\(deviceModel)\"\n        )\n\n        \u002F\u002F Verify no crashes\n        XCTAssertFalse(app.alerts.element.exists)\n    }\n}\n```\n\n### Real-World Example: iPad Pro + 3G Crash\n\n**Scenario**: App works on iPhone 14, crashes on iPad Pro over 3G.\n\n**Why it crashes**:\n1. iPad Pro has larger layout (landscape)\n2. 3G network is slow (latency 100ms+)\n3. Images don't load in time, layout engine crashes\n4. Single-device testing misses this combo\n\n**Test that catches it**:\n```swift\nfunc testLargeLayoutOn3G() {\n    let app = XCUIApplication()\n    \u002F\u002F Running with Network Link Conditioner on 3G profile\n    app.launch()\n\n    \u002F\u002F iPad Pro: Large grid of images\n    app.buttons[\"Browse\"].tap()\n\n    \u002F\u002F Wait longer for images on slow network\n    let firstImage = app.images[\"photoGrid-0\"]\n    XCTAssertTrue(\n        firstImage.waitForExistence(timeout: 20),\n        \"First image must load on slow network\"\n    )\n\n    \u002F\u002F Verify grid loaded without crash\n    let loadedCount = app.images.matching(identifier: NSPredicate(format: \"identifier BEGINSWITH 'photoGrid'\")).count\n    XCTAssertGreater(loadedCount, 5, \"Multiple images should load on 3G\")\n\n    \u002F\u002F No alerts (no crashes)\n    XCTAssertFalse(app.alerts.element.exists, \"App should not crash on large device + slow network\")\n}\n```\n\n### Running Multi-Factor Tests in CI\n\n**In GitHub Actions or Xcode Cloud**:\n```yaml\n- name: Run tests across devices\n  run: |\n    xcodebuild -scheme MyApp \\\n      -testPlan MultiDeviceTestPlan \\\n      test\n```\n\n**Test Plan runs on**:\n- iPhone 14 Pro + LTE\n- iPhone 14 Pro + 3G\n- iPad Pro + LTE\n- iPad Pro + 3G\n\n**Result**: Catch device-specific crashes before App Store submission.\n\n---\n\n## Debugging Crashes Revealed by UI Tests\n\n### Overview\n\nUI tests sometimes reveal crashes that don't happen in manual testing. **Key insight** Automated tests run faster, interact with app differently, and can expose concurrency\u002Ftiming bugs.\n\n**When crashes happen**:\n- ❌ Manual testing: Can't reproduce (works when you run it)\n- ✅ UI Test: Crashes every time (automated repetition finds race condition)\n\n### Recognizing Test-Revealed Crashes\n\n**Signs in test output**:\n```\nFailing test: testPhotoUpload\nError: The app crashed while responding to a UI event\nApp died from an uncaught exception\nStack trace: [EXC_BAD_ACCESS in PhotoViewController]\n```\n\n**Video shows**: App visibly crashes (black screen, immediate termination).\n\n### Systematic Debugging Approach\n\n#### Step 1: Capture Crash Details\n\n**Enable detailed logging**:\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Enable all logging\n    app.launchEnvironment = [\n        \"OS_ACTIVITY_MODE\": \"debug\",\n        \"DYLD_PRINT_STATISTICS\": \"1\"\n    ]\n\n    \u002F\u002F Enable test diagnostics\n    if #available(iOS 17, *) {\n        let options = XCUIApplicationLaunchOptions()\n        options.captureRawLogs = true\n        app.launch(options)\n    } else {\n        app.launch()\n    }\n}\n```\n\n#### Step 2: Reproduce Locally\n\n```swift\nfunc testReproduceCrash() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Run exact sequence that causes crash\n    app.buttons[\"Browse\"].tap()\n    app.buttons[\"Photo Album\"].tap()\n    app.buttons[\"Select All\"].tap()\n    app.buttons[\"Upload\"].tap()\n\n    \u002F\u002F Should crash here\n    let uploadButton = app.buttons[\"Upload\"]\n    XCTAssertFalse(uploadButton.exists, \"App crashed (expected)\")\n\n    \u002F\u002F Don't assert - just let it crash and read logs\n}\n```\n\n**Run test with Console logs visible**:\n- Xcode: View → Navigators → Show Console\n- Watch for exception messages\n\n#### Step 3: Analyze Crash Logs\n\n**Locations**:\n1. Xcode Console (real-time, less detail)\n2. ~\u002FLibrary\u002FLogs\u002FDiagnosticMessages\u002Fcrash_*.log (full details)\n3. Device Settings → Privacy → Analytics → Analytics Data\n\n**Look for**:\n- Thread that crashed\n- Exception type (EXC_BAD_ACCESS, EXC_CRASH, etc.)\n- Stack trace showing which method crashed\n\n**Example crash log**:\n```\nException Type: EXC_BAD_ACCESS (SIGSEGV)\nException Codes: KERN_INVALID_ADDRESS at 0x0000000000000000\nThread 0 Crashed:\n0  MyApp    0x0001a234 -[PhotoViewController reloadPhotos:] + 234\n1  MyApp    0x0001a123 -[PhotoViewController viewDidLoad] + 180\n```\n\n**This tells us**:\n- Crash in `PhotoViewController.reloadPhotos(_:)`\n- Likely null pointer dereference\n- Called from `viewDidLoad`\n\n#### Step 4: Connection to Swift Concurrency Issues\n\n**Most UI test crashes are concurrency bugs** (not specific to UI testing). Reference related skills:\n\n```swift\n\u002F\u002F Common pattern: Race condition in async image loading\nclass PhotoViewController: UIViewController {\n    var photos: [Photo] = []\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        \u002F\u002F ❌ WRONG: Accessing photos array from multiple threads\n        Task {\n            let newPhotos = await fetchPhotos()\n            self.photos = newPhotos  \u002F\u002F May crash if main thread access\n            reloadPhotos()  \u002F\u002F ❌ Crash here\n        }\n    }\n}\n\n\u002F\u002F ✅ CORRECT: Ensure main thread\nclass PhotoViewController: UIViewController {\n    @MainActor\n    var photos: [Photo] = []\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        Task {\n            let newPhotos = await fetchPhotos()\n            await MainActor.run { [weak self] in\n                self?.photos = newPhotos\n                self?.reloadPhotos()  \u002F\u002F ✅ Safe\n            }\n        }\n    }\n}\n```\n\n**For deep crash analysis**: See `axiom-swift-concurrency` skill for @MainActor patterns and `axiom-memory-debugging` skill for thread-safety issues.\n\n#### Step 5: Add Crash-Prevention Tests\n\n**After fixing**:\n```swift\nfunc testPhotosLoadWithoutCrash() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Rapid fire interactions that previously caused crash\n    app.buttons[\"Browse\"].tap()\n    app.buttons[\"Photo Album\"].tap()\n\n    \u002F\u002F Load should complete without crash\n    let photoGrid = app.otherElements[\"photoGrid\"]\n    XCTAssertTrue(photoGrid.waitForExistence(timeout: 10))\n\n    \u002F\u002F No alerts (no crash dialogs)\n    XCTAssertFalse(app.alerts.element.exists)\n}\n```\n\n#### Step 6: Stress Test to Verify Fix\n\n```swift\nfunc testPhotosLoadUnderStress() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Repeat the crash-causing action multiple times\n    for iteration in 0..\u003C10 {\n        app.buttons[\"Browse\"].tap()\n\n        \u002F\u002F Wait for load\n        let grid = app.otherElements[\"photoGrid\"]\n        XCTAssertTrue(grid.waitForExistence(timeout: 10), \"Iteration \\(iteration)\")\n\n        \u002F\u002F Go back\n        app.navigationBars.buttons[\"Back\"].tap()\n        app.buttons[\"Refresh\"].tap()\n    }\n\n    \u002F\u002F Completed without crash\n    XCTAssertTrue(true, \"Stress test passed\")\n}\n```\n\n### Prevention Checklist\n\n#### Before releasing\n- [ ] Run UI tests on slowest network (3G)\n- [ ] Run on largest device (iPad Pro)\n- [ ] Run on oldest supported device (iPhone 12)\n- [ ] Record video of test runs (saves debugging time)\n- [ ] Check for crashes in logs\n- [ ] Run stress tests (10x repeated actions)\n- [ ] Verify @MainActor on UI properties\n- [ ] Check for race conditions in async code\n\n---\n\n## Resources\n\n**WWDC**: 2025-344, 2024-10179, 2023-10175, 2023-10035\n\n**Docs**: \u002Fxctest, \u002Fxcuiautomation\u002Frecording-ui-automation-for-testing, \u002Fxctest\u002Fxctwaiter, \u002Faccessibility\u002Fdelivering_an_exceptional_accessibility_experience, \u002Faccessibility\u002Fperforming_accessibility_testing_for_your_app\n\n**Note**: This skill focuses on reliability patterns and Recording UI Automation. For TDD workflow, see superpowers:test-driven-development.\n\n---\n\n**History:** See git log for changes\n\n","# UI Testing\n\n## Overview\n\nWait for conditions, not arbitrary timeouts. **Core principle** Flaky tests come from guessing how long operations take. Condition-based waiting eliminates race conditions.\n\n**NEW in WWDC 2025**: Recording UI Automation allows you to record interactions, replay across devices\u002Flanguages, and review video recordings of test runs.\n\n## Example Prompts\n\nThese are real questions developers ask that this skill is designed to answer:\n\n#### 1. \"My UI tests pass locally on my Mac but fail in CI. How do I make them more reliable?\"\n→ The skill shows condition-based waiting patterns that work across devices\u002Fspeeds, eliminating CI timing differences\n\n#### 2. \"My tests use sleep(2) and sleep(5) but they're still flaky. How do I replace arbitrary timeouts with real conditions?\"\n→ The skill demonstrates waitForExistence, XCTestExpectation, and polling patterns for data loads, network requests, and animations\n\n#### 3. \"I just recorded a test using Xcode 26's Recording UI Automation. How do I review the video and debug failures?\"\n→ The skill covers Video Debugging workflows to analyze recordings and find the exact step where tests fail\n\n#### 4. \"My test is failing on iPad but passing on iPhone. How do I write tests that work across all device sizes?\"\n→ The skill explains multi-factor testing strategies and device-independent predicates for robust cross-device testing\n\n#### 5. \"I want to write tests that are not flaky. What are the critical patterns I need to know?\"\n→ The skill provides condition-based waiting templates, accessibility-first patterns, and the decision tree for reliable test architecture\n\n---\n\n## Red Flags — Test Reliability Issues\n\nIf you see ANY of these, suspect timing issues:\n- Tests pass locally, fail in CI (timing differences)\n- Tests sometimes pass, sometimes fail (race conditions)\n- Tests use `sleep()` or `Thread.sleep()` (arbitrary delays)\n- Tests fail with \"UI element not found\" then pass on retry\n- Long test runs (waiting for worst-case scenarios)\n\n## Quick Decision Tree\n\n```\nTest failing?\n├─ Element not found?\n│  └─ Use waitForExistence(timeout:) not sleep()\n├─ Passes locally, fails CI?\n│  └─ Replace sleep() with condition polling\n├─ Animation causing issues?\n│  └─ Wait for animation completion, don't disable\n└─ Network request timing?\n   └─ Use XCTestExpectation or waitForExistence\n```\n\n## Core Pattern: Condition-Based Waiting\n\n**❌ WRONG (Arbitrary Timeout)**:\n```swift\nfunc testButtonAppears() {\n    app.buttons[\"Login\"].tap()\n    sleep(2)  \u002F\u002F ❌ Guessing it takes 2 seconds\n    XCTAssertTrue(app.buttons[\"Dashboard\"].exists)\n}\n```\n\n**✅ CORRECT (Wait for Condition)**:\n```swift\nfunc testButtonAppears() {\n    app.buttons[\"Login\"].tap()\n    let dashboard = app.buttons[\"Dashboard\"]\n    XCTAssertTrue(dashboard.waitForExistence(timeout: 5))\n}\n```\n\n## Common UI Testing Patterns\n\n### Pattern 1: Waiting for Elements\n\n```swift\n\u002F\u002F Wait for element to appear\nfunc waitForElement(_ element: XCUIElement, timeout: TimeInterval = 5) -> Bool {\n    return element.waitForExistence(timeout: timeout)\n}\n\n\u002F\u002F Usage\nXCTAssertTrue(waitForElement(app.buttons[\"Submit\"]))\n```\n\n### Pattern 2: Waiting for Element to Disappear\n\n```swift\nfunc waitForElementToDisappear(_ element: XCUIElement, timeout: TimeInterval = 5) -> Bool {\n    let predicate = NSPredicate(format: \"exists == false\")\n    let expectation = XCTNSPredicateExpectation(predicate: predicate, object: element)\n    let result = XCTWaiter().wait(for: [expectation], timeout: timeout)\n    return result == .completed\n}\n\n\u002F\u002F Usage\nXCTAssertTrue(waitForElementToDisappear(app.activityIndicators[\"Loading\"]))\n```\n\n### Pattern 3: Waiting for Specific State\n\n```swift\nfunc waitForButton(_ button: XCUIElement, toBeEnabled enabled: Bool, timeout: TimeInterval = 5) -> Bool {\n    let predicate = NSPredicate(format: \"isEnabled == %@\", NSNumber(value: enabled))\n    let expectation = XCTNSPredicateExpectation(predicate: predicate, object: button)\n    let result = XCTWaiter().wait(for: [expectation], timeout: timeout)\n    return result == .completed\n}\n\n\u002F\u002F Usage\nlet submitButton = app.buttons[\"Submit\"]\nXCTAssertTrue(waitForButton(submitButton, toBeEnabled: true))\nsubmitButton.tap()\n```\n\n### Pattern 4: Accessibility Identifiers\n\n**Set in app**:\n```swift\nButton(\"Submit\") {\n    \u002F\u002F action\n}\n.accessibilityIdentifier(\"submitButton\")\n```\n\n**Use in tests**:\n```swift\nfunc testSubmitButton() {\n    let submitButton = app.buttons[\"submitButton\"]  \u002F\u002F Uses identifier, not label\n    XCTAssertTrue(submitButton.waitForExistence(timeout: 5))\n    submitButton.tap()\n}\n```\n\n**Why**: Accessibility identifiers don't change with localization, remain stable across UI updates.\n\n### Pattern 5: Network Request Delays\n\n```swift\nfunc testDataLoads() {\n    app.buttons[\"Refresh\"].tap()\n\n    \u002F\u002F Wait for loading indicator to disappear\n    let loadingIndicator = app.activityIndicators[\"Loading\"]\n    XCTAssertTrue(waitForElementToDisappear(loadingIndicator, timeout: 10))\n\n    \u002F\u002F Now verify data loaded\n    XCTAssertTrue(app.cells.count > 0)\n}\n```\n\n### Pattern 6: Animation Handling\n\n```swift\nfunc testAnimatedTransition() {\n    app.buttons[\"Next\"].tap()\n\n    \u002F\u002F Wait for destination view to appear\n    let destinationView = app.otherElements[\"DestinationView\"]\n    XCTAssertTrue(destinationView.waitForExistence(timeout: 2))\n\n    \u002F\u002F Optional: Wait a bit more for animation to settle\n    \u002F\u002F Only if absolutely necessary\n    RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.3))\n}\n```\n\n## Testing Checklist\n\n### Before Writing Tests\n- [ ] Use accessibility identifiers for all interactive elements\n- [ ] Avoid hardcoded labels (use identifiers instead)\n- [ ] Plan for network delays and animations\n- [ ] Choose appropriate timeouts (2s UI, 10s network)\n\n### When Writing Tests\n- [ ] Use `waitForExistence()` not `sleep()`\n- [ ] Use predicates for complex conditions\n- [ ] Test both success and failure paths\n- [ ] Make tests independent (can run in any order)\n\n### After Writing Tests\n- [ ] Run tests 10 times locally (catch flakiness)\n- [ ] Run tests on slowest supported device\n- [ ] Run tests in CI environment\n- [ ] Check test duration (if >30s per test, optimize)\n\n## Xcode UI Testing Tips\n\n### Launch Arguments for Testing\n\n```swift\nfunc testExample() {\n    let app = XCUIApplication()\n    app.launchArguments = [\"UI-Testing\"]\n    app.launch()\n}\n```\n\nIn app code:\n```swift\nif ProcessInfo.processInfo.arguments.contains(\"UI-Testing\") {\n    \u002F\u002F Use mock data, skip onboarding, etc.\n}\n```\n\n### Faster Test Execution\n\n```swift\noverride func setUpWithError() throws {\n    continueAfterFailure = false  \u002F\u002F Stop on first failure\n}\n```\n\n### Debugging Failing Tests\n\n```swift\nfunc testExample() {\n    \u002F\u002F Take screenshot on failure\n    addUIInterruptionMonitor(withDescription: \"Alert\") { alert in\n        alert.buttons[\"OK\"].tap()\n        return true\n    }\n\n    \u002F\u002F Print element hierarchy\n    print(app.debugDescription)\n}\n```\n\n## Common Mistakes\n\n### ❌ Using sleep() for Everything\n```swift\nsleep(5)  \u002F\u002F ❌ Wastes time if operation completes in 1s\n```\n\n### ❌ Not Handling Animations\n```swift\napp.buttons[\"Next\"].tap()\nXCTAssertTrue(app.buttons[\"Back\"].exists)  \u002F\u002F ❌ May fail during animation\n```\n\n### ❌ Hardcoded Text Labels\n```swift\napp.buttons[\"Submit\"].tap()  \u002F\u002F ❌ Breaks with localization\n```\n\n### ❌ Tests Depend on Each Other\n```swift\n\u002F\u002F ❌ Test 2 assumes Test 1 ran first\nfunc test1_Login() { \u002F* ... *\u002F }\nfunc test2_ViewDashboard() { \u002F* assumes logged in *\u002F }\n```\n\n### ❌ No Timeout Strategy\n```swift\nelement.waitForExistence(timeout: 100)  \u002F\u002F ❌ Too long\nelement.waitForExistence(timeout: 0.1)  \u002F\u002F ❌ Too short\n```\n\n**Use appropriate timeouts**:\n- UI animations: 2-3 seconds\n- Network requests: 10 seconds\n- Complex operations: 30 seconds max\n\n## Real-World Impact\n\n**Before** (using sleep()):\n- Test suite: 15 minutes (waiting for worst-case)\n- Flaky tests: 20% failure rate\n- CI failures: 50% require retry\n\n**After** (condition-based waiting):\n- Test suite: 5 minutes (waits only as needed)\n- Flaky tests: \u003C2% failure rate\n- CI failures: \u003C5% require retry\n\n**Key insight** Tests finish faster AND are more reliable when waiting for actual conditions instead of guessing times.\n\n---\n\n## Recording UI Automation\n\n### Overview\n\n**NEW in Xcode 26**: Record, replay, and review UI automation tests with video recordings.\n\n**Three Phases**:\n1. **Record** — Capture interactions (taps, swipes, hardware button presses) as Swift code\n2. **Replay** — Run across multiple devices, languages, regions, orientations\n3. **Review** — Watch video recordings, analyze failures, view UI element overlays\n\n**Supported Platforms**: iOS, iPadOS, macOS, watchOS, tvOS, axiom-visionOS (Designed for iPad)\n\n### How UI Automation Works\n\n**Key Principles**:\n- UI automation interacts with your app **as a person does** using gestures and hardware events\n- Runs **completely independently** from your app (app models\u002Fdata not directly accessible)\n- Uses **accessibility framework** as underlying technology\n- Tells OS which gestures to perform, then waits for completion **synchronously** one at a time\n\n**Actions include**:\n- Launching your app\n- Interacting with buttons and navigation\n- Setting system state (Dark Mode, axiom-localization, etc.)\n- Setting simulated location\n\n### Accessibility is the Foundation\n\n**Critical Understanding**: Accessibility provides information directly to UI automation.\n\nWhat accessibility sees:\n- Element types (button, text, image, etc.)\n- Labels (visible text)\n- Values (current state for checkboxes, etc.)\n- Frames (element positions)\n- **Identifiers** (accessibility identifiers — NOT localized)\n\n**Best Practice**: Great accessibility experience = great UI automation experience.\n\n### Preparing Your App for Recording\n\n#### Step 1: Add Accessibility Identifiers\n\n**SwiftUI**:\n```swift\nButton(\"Submit\") {\n    \u002F\u002F action\n}\n.accessibilityIdentifier(\"submitButton\")\n\n\u002F\u002F Make identifiers specific to instance\nList(landmarks) { landmark in\n    LandmarkRow(landmark)\n        .accessibilityIdentifier(\"landmark-\\(landmark.id)\")\n}\n```\n\n**UIKit**:\n```swift\nlet button = UIButton()\nbutton.accessibilityIdentifier = \"submitButton\"\n\n\u002F\u002F Use index for table cells\ncell.accessibilityIdentifier = \"cell-\\(indexPath.row)\"\n```\n\n**Good identifiers are**:\n- ✅ Unique within entire app\n- ✅ Descriptive of element contents\n- ✅ Static (don't react to content changes)\n- ✅ Not localized (same across languages)\n\n**Why identifiers matter**:\n- Titles\u002Fdescriptions may change, identifiers remain stable\n- Work across localized strings\n- Uniquely identify elements with dynamic content\n\n**Pro Tip**: Use Xcode coding assistant to add identifiers:\n```\nPrompt: \"Add accessibility identifiers to the relevant parts of this view\"\n```\n\n#### Step 2: Review Accessibility with Accessibility Inspector\n\n**Launch Accessibility Inspector**:\n- Xcode menu → Open Developer Tool → Accessibility Inspector\n- Or: Launch from Spotlight\n\n**Features**:\n1. **Element Inspector** — List accessibility values for any view\n2. **Property details** — Click property name for documentation\n3. **Platform support** — Works on all Apple platforms\n\n**What to check**:\n- Elements have labels\n- Interactive elements have types (button, not just text)\n- Values set for stateful elements (checkboxes, toggles)\n- Identifiers set for elements with dynamic\u002Flocalized content\n\n**Sample Code Reference**: [Delivering an exceptional accessibility experience](https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Faccessibility\u002Fdelivering_an_exceptional_accessibility_experience)\n\n#### Step 3: Add UI Testing Target\n\n1. Open project settings in Xcode\n2. Click \"+\" below targets list\n3. Select **UI Testing Bundle**\n4. Click Finish\n\n**Result**: New UI test folder with template tests added to project.\n\n### Recording Interactions\n\n#### Starting a Recording (Xcode 26)\n\n1. Open UI test source file\n2. **Popover appears** explaining how to start recording (first time only)\n3. Click **\"Start Recording\"** button in editor gutter\n4. Xcode builds and launches app in Simulator\u002Fdevice\n\n**During Recording**:\n- Interact with app normally (taps, swipes, text entry, etc.)\n- Code representing interactions appears in source editor in real-time\n- Recording updates as you type (e.g., text field entries)\n\n**Stopping Recording**:\n- Click **\"Stop Run\"** button in Xcode\n\n#### Example Recording Session\n\n```swift\nfunc testCreateAustralianCollection() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Tap \"Collections\" tab (recorded automatically)\n    app.tabBars.buttons[\"Collections\"].tap()\n\n    \u002F\u002F Tap \"+\" to add new collection\n    app.navigationBars.buttons[\"Add\"].tap()\n\n    \u002F\u002F Tap \"Edit\" button\n    app.buttons[\"Edit\"].tap()\n\n    \u002F\u002F Type collection name\n    app.textFields.firstMatch.tap()\n    app.textFields.firstMatch.typeText(\"Max's Australian Adventure\")\n\n    \u002F\u002F Tap \"Edit Landmarks\"\n    app.buttons[\"Edit Landmarks\"].tap()\n\n    \u002F\u002F Add landmarks\n    app.tables.cells.containing(.staticText, identifier:\"Great Barrier Reef\").buttons[\"Add\"].tap()\n    app.tables.cells.containing(.staticText, identifier:\"Uluru\").buttons[\"Add\"].tap()\n\n    \u002F\u002F Tap checkmark to save\n    app.navigationBars.buttons[\"Done\"].tap()\n}\n```\n\n#### Reviewing Recorded Code\n\nAfter recording, **review and adjust queries**:\n\n**Multiple Options**: Each line has dropdown showing alternative ways to address element.\n\n**Selection Recommendations**:\n1. **For localized strings** (text, button labels): Choose accessibility identifier if available\n2. **For deeply nested views**: Choose shortest query (stays resilient as app changes)\n3. **For dynamic content** (timestamps, temperature): Use generic query or identifier\n\n**Example**:\n```swift\n\u002F\u002F Recorded options for text field:\napp.textFields[\"Collection Name\"]              \u002F\u002F ❌ Breaks if label localizes\napp.textFields[\"collectionNameField\"]          \u002F\u002F ✅ Uses identifier\napp.textFields.element(boundBy: 0)             \u002F\u002F ✅ Position-based\napp.textFields.firstMatch                      \u002F\u002F ✅ Generic, shortest\n```\n\n**Choose shortest, most stable query** for your needs.\n\n### Adding Validations\n\nAfter recording, **add assertions** to verify expected behavior:\n\n#### Wait for Existence\n\n```swift\n\u002F\u002F Validate collection created\nlet collection = app.buttons[\"Max's Australian Adventure\"]\nXCTAssertTrue(collection.waitForExistence(timeout: 5))\n```\n\n#### Wait for Property Changes\n\n```swift\n\u002F\u002F Wait for button to become enabled\nlet submitButton = app.buttons[\"Submit\"]\nXCTAssertTrue(submitButton.wait(for: .enabled, toEqual: true, timeout: 5))\n```\n\n#### Combine with XCTAssert\n\n```swift\n\u002F\u002F Fail test if element doesn't appear\nlet landmark = app.staticTexts[\"Great Barrier Reef\"]\nXCTAssertTrue(landmark.waitForExistence(timeout: 5), \"Landmark should appear in collection\")\n```\n\n### Advanced Automation APIs\n\n#### Setup Device State\n\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Set device orientation\n    XCUIDevice.shared.orientation = .landscapeLeft\n\n    \u002F\u002F Set appearance mode\n    app.launchArguments += [\"-UIUserInterfaceStyle\", \"dark\"]\n\n    \u002F\u002F Simulate location\n    let location = XCUILocation(location: CLLocation(latitude: 37.7749, longitude: -122.4194))\n    app.launchArguments += [\"-SimulatedLocation\", location.description]\n\n    app.launch()\n}\n```\n\n#### Launch Arguments & Environment\n\n```swift\nfunc testWithMockData() {\n    let app = XCUIApplication()\n\n    \u002F\u002F Pass arguments to app\n    app.launchArguments = [\"-UI-Testing\", \"-UseMockData\"]\n\n    \u002F\u002F Set environment variables\n    app.launchEnvironment = [\"API_URL\": \"https:\u002F\u002Fmock.api.com\"]\n\n    app.launch()\n}\n```\n\nIn app code:\n```swift\nif ProcessInfo.processInfo.arguments.contains(\"-UI-Testing\") {\n    \u002F\u002F Use mock data, skip onboarding\n}\n```\n\n#### Custom URL Schemes\n\n```swift\n\u002F\u002F Open app to specific URL\nlet app = XCUIApplication()\napp.open(URL(string: \"myapp:\u002F\u002Flandmark\u002F123\")!)\n\n\u002F\u002F Open URL with system default app (global version)\nXCUIApplication.open(URL(string: \"https:\u002F\u002Fexample.com\")!)\n```\n\n#### Accessibility Audits in Tests\n\n```swift\nfunc testAccessibility() throws {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Perform accessibility audit\n    try app.performAccessibilityAudit()\n}\n```\n\n**Reference**: [Perform accessibility audits for your app — WWDC23](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2023\u002F10035\u002F)\n\n### Test Plans for Multiple Configurations\n\n**Test Plans** let you:\n- Include\u002Fexclude individual tests\n- Set system settings (language, region, appearance)\n- Configure test properties (timeouts, repetitions, parallelization)\n- Associate with schemes for specific build settings\n\n#### Creating Test Plan\n\n1. Create new or use existing test plan\n2. Add\u002Fremove tests on first screen\n3. Switch to **Configurations** tab\n\n#### Adding Multiple Languages\n\n```\nConfigurations:\n├─ English\n├─ German (longer strings)\n├─ Arabic (right-to-left)\n└─ Hebrew (right-to-left)\n```\n\n**Each locale** = separate configuration in test plan.\n\n**Settings**:\n- Focused for specific locale\n- Shared across all configurations\n\n#### Video & Screenshot Capture\n\n**In Configurations tab**:\n- **Capture screenshots**: On\u002FOff\n- **Capture video**: On\u002FOff\n- **Keep media**: \"Only failures\" or \"On, and keep all\"\n\n**Defaults**: Videos\u002Fscreenshots kept only for failing runs (for review).\n\n**\"On, and keep all\" use cases**:\n- Documentation\n- Tutorials\n- Marketing materials\n\n**Reference**: [Author fast and reliable tests for Xcode Cloud — WWDC22](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2022\u002F110371\u002F)\n\n### Replaying Tests in Xcode Cloud\n\n**Xcode Cloud** = built-in service for:\n- Building app\n- Running tests\n- Uploading to App Store\n- All in cloud without using team devices\n\n**Workflow configuration**:\n- Same test plan used locally\n- Runs on multiple devices and configurations\n- Videos\u002Fresults available in App Store Connect\n\n**Viewing Results**:\n- Xcode: Xcode Cloud section\n- App Store Connect: Xcode Cloud section\n- See build info, logs, failure descriptions, video recordings\n\n**Team Access**: Entire team can see run history and download results\u002Fvideos.\n\n**Reference**: [Create practical workflows in Xcode Cloud — WWDC23](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2023\u002F10269\u002F)\n\n### Reviewing Test Results with Videos\n\n#### Accessing Test Report\n\n1. Click **Test** button in Xcode\n2. Double-click failing run to see video + description\n\n**Features**:\n- **Runs dropdown** — Switch between video recordings of different configurations (languages, devices)\n- **Save video** — Secondary click → Save\n- **Play\u002Fpause** — Video playback with UI interaction overlays\n- **Timeline dots** — UI interactions shown as dots on timeline\n- **Jump to failure** — Click failure diamond on timeline\n\n#### UI Element Overlay at Failure\n\n**At moment of failure**:\n- Click timeline failure point\n- **Overlay shows all UI elements** present on screen\n- Click any element to see code recommendations for addressing it\n- **Show All** — See alternative examples\n\n**Workflow**:\n1. Identify what was actually present (vs what test expected)\n2. Click element to get query code\n3. Secondary click → Copy code\n4. **View Source** → Go directly to test\n5. Paste corrected code\n\n**Example**:\n```swift\n\u002F\u002F Test expected:\nlet button = app.buttons[\"Max's Australian Adventure\"]\n\n\u002F\u002F But overlay shows it's actually text, not button:\nlet text = app.staticTexts[\"Max's Australian Adventure\"] \u002F\u002F ✅ Correct\n```\n\n#### Running Test in Different Language\n\nClick test diamond → Select configuration (e.g., Arabic) → Watch automation run in right-to-left layout.\n\n**Validates**: Same automation works across languages\u002Flayouts.\n\n**Reference**: [Fix failures faster with Xcode test reports — WWDC23](https:\u002F\u002Fdeveloper.apple.com\u002Fvideos\u002Fplay\u002Fwwdc2023\u002F10175\u002F)\n\n### Recording UI Automation Checklist\n\n#### Before Recording\n- [ ] Add accessibility identifiers to interactive elements\n- [ ] Review app with Accessibility Inspector\n- [ ] Add UI Testing Bundle target to project\n- [ ] Plan workflow to record (user journey)\n\n#### During Recording\n- [ ] Interact naturally with app\n- [ ] Record complete user journeys (not individual taps)\n- [ ] Check code generates as you interact\n- [ ] Stop recording when workflow complete\n\n#### After Recording\n- [ ] Review recorded code options (dropdown on each line)\n- [ ] Choose stable queries (identifiers > labels)\n- [ ] Add validations (waitForExistence, XCTAssert)\n- [ ] Add setup code (device state, launch arguments)\n- [ ] Run test to verify it passes\n\n#### Test Plan Configuration\n- [ ] Create\u002Fupdate test plan\n- [ ] Add multiple language configurations\n- [ ] Include right-to-left languages (Arabic, Hebrew)\n- [ ] Configure video\u002Fscreenshot capture settings\n- [ ] Set appropriate timeouts for network tests\n\n#### Running & Reviewing\n- [ ] Run test locally across configurations\n- [ ] Review video recordings for failures\n- [ ] Use UI element overlay to debug failures\n- [ ] Run in Xcode Cloud for team visibility\n- [ ] Download and share videos if needed\n\n## Network Conditioning in Tests\n\n### Overview\n\nUI tests can pass on fast networks but fail on 3G\u002FLTE. **Network Link Conditioner** simulates real-world network conditions to catch timing-sensitive crashes.\n\n**Critical scenarios**:\n- ❌ iPad Pro over Wi-Fi (fast) → pass\n- ❌ iPad Pro over 3G (slow) → crash\n- ✅ Test both to catch device-specific failures\n\n### Setup Network Link Conditioner\n\n**Install Network Link Conditioner**:\n1. Download from [Apple's Additional Tools for Xcode](https:\u002F\u002Fdeveloper.apple.com\u002Fdownload\u002Fall\u002F)\n2. Search: \"Network Link Conditioner\"\n3. Install: `sudo open Network\\ Link\\ Conditioner.pkg`\n\n**Verify Installation**:\n```bash\n# Check if installed\nls ~\u002FLibrary\u002FApplication\\ Support\u002FNetwork\\ Link\\ Conditioner\u002F\n```\n\n**Enable in Tests**:\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Launch with network conditioning argument\n    app.launchArguments = [\"-com.apple.CoreSimulator.CoreSimulatorService\", \"-networkShaping\"]\n    app.launch()\n}\n```\n\n### Common Network Profiles\n\n**3G Profile** (most failures occur here):\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Simulate 3G (type in launch arguments)\n    app.launchEnvironment = [\n        \"SIMULATOR_UDID\": ProcessInfo.processInfo.environment[\"SIMULATOR_UDID\"] ?? \"\",\n        \"NETWORK_PROFILE\": \"3G\"\n    ]\n    app.launch()\n}\n```\n\n**Manual Network Conditioning** (macOS System Preferences):\n1. Open System Preferences → Network\n2. Click \"Network Link Conditioner\" (installed above)\n3. Select profile: 3G, LTE, WiFi\n4. Click \"Start\"\n5. Run tests (they'll use throttled network)\n\n### Real-World Example: Photo Upload with Network Throttling\n\n**❌ Without Network Conditioning**:\n```swift\nfunc testPhotoUpload() {\n    app.buttons[\"Upload Photo\"].tap()\n\n    \u002F\u002F Passes locally (fast network)\n    XCTAssertTrue(app.staticTexts[\"Upload complete\"].waitForExistence(timeout: 5))\n}\n\u002F\u002F ✅ Passes locally, ❌ FAILS on 3G with timeout\n```\n\n**✅ With Network Conditioning**:\n```swift\nfunc testPhotoUploadOn3G() {\n    let app = XCUIApplication()\n    \u002F\u002F Network Link Conditioner running (3G profile)\n    app.launch()\n\n    app.buttons[\"Upload Photo\"].tap()\n\n    \u002F\u002F Increase timeout for 3G\n    XCTAssertTrue(app.staticTexts[\"Upload complete\"].waitForExistence(timeout: 30))\n\n    \u002F\u002F Verify no crash occurred\n    XCTAssertFalse(app.alerts.element.exists, \"App should not crash on 3G\")\n}\n```\n\n**Key differences**:\n- Longer timeout (30s instead of 5s)\n- Check for crashes\n- Run on slowest expected network\n\n---\n\n## Multi-Factor Testing: Device Size + Network Speed\n\n### The Problem\n\nTests can pass on device A but fail on device B due to layout differences + network delays. **Multi-factor testing** catches these combinations.\n\n**Common failure patterns**:\n- ✅ iPhone 14 Pro (compact, fast network)\n- ❌ iPad Pro 12.9 (large, 3G network) → crashes\n- ✅ iPhone 15 (compact, LTE)\n- ❌ iPhone 12 (older GPU, 3G) → timeout\n\n### Test Plan Configuration for Multiple Devices\n\n**Create Test Plan in Xcode**:\n1. File → New → Test Plan\n2. Select tests to include\n3. Click \"Configurations\" tab\n4. Add configurations for each device\u002Fnetwork combo\n\n**Example Configuration Matrix**:\n```\nConfigurations:\n├─ iPhone 14 Pro + LTE\n├─ iPhone 14 Pro + 3G\n├─ iPad Pro 12.9 + LTE\n├─ iPad Pro 12.9 + 3G  (⚠️ Most failures here)\n└─ iPhone 12 + 3G      (⚠️ Older device)\n```\n\n**In Test Plan UI**:\n- Device: iPhone 14 Pro \u002F iPad Pro 12.9\n- OS Version: Latest\n- Locale: English\n- Network Profile: LTE \u002F 3G\n\n### Programmatic Device-Specific Testing\n\n```swift\nimport XCTest\n\nfinal class MultiFactorUITests: XCTestCase {\n    var deviceModel: String { UIDevice.current.model }\n\n    override func setUpWithError() throws {\n        let app = XCUIApplication()\n        app.launch()\n\n        \u002F\u002F Adjust timeouts based on device\n        switch deviceModel {\n        case \"iPad\" where UIScreen.main.bounds.width > 1000:\n            \u002F\u002F iPad Pro - larger layout, slower rendering\n            app.launchEnvironment[\"TEST_TIMEOUT\"] = \"30\"\n        case \"iPhone\":\n            \u002F\u002F iPhone - compact, standard timeout\n            app.launchEnvironment[\"TEST_TIMEOUT\"] = \"10\"\n        default:\n            app.launchEnvironment[\"TEST_TIMEOUT\"] = \"15\"\n        }\n    }\n\n    func testListLoadingAcrossDevices() {\n        let app = XCUIApplication()\n        let timeout = Double(app.launchEnvironment[\"TEST_TIMEOUT\"] ?? \"10\") ?? 10\n\n        app.buttons[\"Refresh\"].tap()\n\n        \u002F\u002F Wait for list to load (timeout varies by device)\n        XCTAssertTrue(\n            app.tables.cells.count > 0,\n            \"List should load on \\(deviceModel)\"\n        )\n\n        \u002F\u002F Verify no crashes\n        XCTAssertFalse(app.alerts.element.exists)\n    }\n}\n```\n\n### Real-World Example: iPad Pro + 3G Crash\n\n**Scenario**: App works on iPhone 14, crashes on iPad Pro over 3G.\n\n**Why it crashes**:\n1. iPad Pro has larger layout (landscape)\n2. 3G network is slow (latency 100ms+)\n3. Images don't load in time, layout engine crashes\n4. Single-device testing misses this combo\n\n**Test that catches it**:\n```swift\nfunc testLargeLayoutOn3G() {\n    let app = XCUIApplication()\n    \u002F\u002F Running with Network Link Conditioner on 3G profile\n    app.launch()\n\n    \u002F\u002F iPad Pro: Large grid of images\n    app.buttons[\"Browse\"].tap()\n\n    \u002F\u002F Wait longer for images on slow network\n    let firstImage = app.images[\"photoGrid-0\"]\n    XCTAssertTrue(\n        firstImage.waitForExistence(timeout: 20),\n        \"First image must load on slow network\"\n    )\n\n    \u002F\u002F Verify grid loaded without crash\n    let loadedCount = app.images.matching(identifier: NSPredicate(format: \"identifier BEGINSWITH 'photoGrid'\")).count\n    XCTAssertGreater(loadedCount, 5, \"Multiple images should load on 3G\")\n\n    \u002F\u002F No alerts (no crashes)\n    XCTAssertFalse(app.alerts.element.exists, \"App should not crash on large device + slow network\")\n}\n```\n\n### Running Multi-Factor Tests in CI\n\n**In GitHub Actions or Xcode Cloud**:\n```yaml\n- name: Run tests across devices\n  run: |\n    xcodebuild -scheme MyApp \\\n      -testPlan MultiDeviceTestPlan \\\n      test\n```\n\n**Test Plan runs on**:\n- iPhone 14 Pro + LTE\n- iPhone 14 Pro + 3G\n- iPad Pro + LTE\n- iPad Pro + 3G\n\n**Result**: Catch device-specific crashes before App Store submission.\n\n---\n\n## Debugging Crashes Revealed by UI Tests\n\n### Overview\n\nUI tests sometimes reveal crashes that don't happen in manual testing. **Key insight** Automated tests run faster, interact with app differently, and can expose concurrency\u002Ftiming bugs.\n\n**When crashes happen**:\n- ❌ Manual testing: Can't reproduce (works when you run it)\n- ✅ UI Test: Crashes every time (automated repetition finds race condition)\n\n### Recognizing Test-Revealed Crashes\n\n**Signs in test output**:\n```\nFailing test: testPhotoUpload\nError: The app crashed while responding to a UI event\nApp died from an uncaught exception\nStack trace: [EXC_BAD_ACCESS in PhotoViewController]\n```\n\n**Video shows**: App visibly crashes (black screen, immediate termination).\n\n### Systematic Debugging Approach\n\n#### Step 1: Capture Crash Details\n\n**Enable detailed logging**:\n```swift\noverride func setUpWithError() throws {\n    let app = XCUIApplication()\n\n    \u002F\u002F Enable all logging\n    app.launchEnvironment = [\n        \"OS_ACTIVITY_MODE\": \"debug\",\n        \"DYLD_PRINT_STATISTICS\": \"1\"\n    ]\n\n    \u002F\u002F Enable test diagnostics\n    if #available(iOS 17, *) {\n        let options = XCUIApplicationLaunchOptions()\n        options.captureRawLogs = true\n        app.launch(options)\n    } else {\n        app.launch()\n    }\n}\n```\n\n#### Step 2: Reproduce Locally\n\n```swift\nfunc testReproduceCrash() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Run exact sequence that causes crash\n    app.buttons[\"Browse\"].tap()\n    app.buttons[\"Photo Album\"].tap()\n    app.buttons[\"Select All\"].tap()\n    app.buttons[\"Upload\"].tap()\n\n    \u002F\u002F Should crash here\n    let uploadButton = app.buttons[\"Upload\"]\n    XCTAssertFalse(uploadButton.exists, \"App crashed (expected)\")\n\n    \u002F\u002F Don't assert - just let it crash and read logs\n}\n```\n\n**Run test with Console logs visible**:\n- Xcode: View → Navigators → Show Console\n- Watch for exception messages\n\n#### Step 3: Analyze Crash Logs\n\n**Locations**:\n1. Xcode Console (real-time, less detail)\n2. ~\u002FLibrary\u002FLogs\u002FDiagnosticMessages\u002Fcrash_*.log (full details)\n3. Device Settings → Privacy → Analytics → Analytics Data\n\n**Look for**:\n- Thread that crashed\n- Exception type (EXC_BAD_ACCESS, EXC_CRASH, etc.)\n- Stack trace showing which method crashed\n\n**Example crash log**:\n```\nException Type: EXC_BAD_ACCESS (SIGSEGV)\nException Codes: KERN_INVALID_ADDRESS at 0x0000000000000000\nThread 0 Crashed:\n0  MyApp    0x0001a234 -[PhotoViewController reloadPhotos:] + 234\n1  MyApp    0x0001a123 -[PhotoViewController viewDidLoad] + 180\n```\n\n**This tells us**:\n- Crash in `PhotoViewController.reloadPhotos(_:)`\n- Likely null pointer dereference\n- Called from `viewDidLoad`\n\n#### Step 4: Connection to Swift Concurrency Issues\n\n**Most UI test crashes are concurrency bugs** (not specific to UI testing). Reference related skills:\n\n```swift\n\u002F\u002F Common pattern: Race condition in async image loading\nclass PhotoViewController: UIViewController {\n    var photos: [Photo] = []\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        \u002F\u002F ❌ WRONG: Accessing photos array from multiple threads\n        Task {\n            let newPhotos = await fetchPhotos()\n            self.photos = newPhotos  \u002F\u002F May crash if main thread access\n            reloadPhotos()  \u002F\u002F ❌ Crash here\n        }\n    }\n}\n\n\u002F\u002F ✅ CORRECT: Ensure main thread\nclass PhotoViewController: UIViewController {\n    @MainActor\n    var photos: [Photo] = []\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        Task {\n            let newPhotos = await fetchPhotos()\n            await MainActor.run { [weak self] in\n                self?.photos = newPhotos\n                self?.reloadPhotos()  \u002F\u002F ✅ Safe\n            }\n        }\n    }\n}\n```\n\n**For deep crash analysis**: See `axiom-swift-concurrency` skill for @MainActor patterns and `axiom-memory-debugging` skill for thread-safety issues.\n\n#### Step 5: Add Crash-Prevention Tests\n\n**After fixing**:\n```swift\nfunc testPhotosLoadWithoutCrash() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Rapid fire interactions that previously caused crash\n    app.buttons[\"Browse\"].tap()\n    app.buttons[\"Photo Album\"].tap()\n\n    \u002F\u002F Load should complete without crash\n    let photoGrid = app.otherElements[\"photoGrid\"]\n    XCTAssertTrue(photoGrid.waitForExistence(timeout: 10))\n\n    \u002F\u002F No alerts (no crash dialogs)\n    XCTAssertFalse(app.alerts.element.exists)\n}\n```\n\n#### Step 6: Stress Test to Verify Fix\n\n```swift\nfunc testPhotosLoadUnderStress() {\n    let app = XCUIApplication()\n    app.launch()\n\n    \u002F\u002F Repeat the crash-causing action multiple times\n    for iteration in 0..\u003C10 {\n        app.buttons[\"Browse\"].tap()\n\n        \u002F\u002F Wait for load\n        let grid = app.otherElements[\"photoGrid\"]\n        XCTAssertTrue(grid.waitForExistence(timeout: 10), \"Iteration \\(iteration)\")\n\n        \u002F\u002F Go back\n        app.navigationBars.buttons[\"Back\"].tap()\n        app.buttons[\"Refresh\"].tap()\n    }\n\n    \u002F\u002F Completed without crash\n    XCTAssertTrue(true, \"Stress test passed\")\n}\n```\n\n### Prevention Checklist\n\n#### Before releasing\n- [ ] Run UI tests on slowest network (3G)\n- [ ] Run on largest device (iPad Pro)\n- [ ] Run on oldest supported device (iPhone 12)\n- [ ] Record video of test runs (saves debugging time)\n- [ ] Check for crashes in logs\n- [ ] Run stress tests (10x repeated actions)\n- [ ] Verify @MainActor on UI properties\n- [ ] Check for race conditions in async code\n\n---\n\n## Resources\n\n**WWDC**: 2025-344, 2024-10179, 2023-10175, 2023-10035\n\n**Docs**: \u002Fxctest, \u002Fxcuiautomation\u002Frecording-ui-automation-for-testing, \u002Fxctest\u002Fxctwaiter, \u002Faccessibility\u002Fdelivering_an_exceptional_accessibility_experience, \u002Faccessibility\u002Fperforming_accessibility_testing_for_your_app\n\n**Note**: This skill focuses on reliability patterns and Recording UI Automation. For TDD workflow, see superpowers:test-driven-development.\n\n---\n\n**History:** See git log for changes\n\n",{"name":5,"license":15,"metadata":66,"description":7},{"version":67,"last-updated":68},"2.1.0","WWDC 2025 (Updated with production debugging patterns)","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-ui-testing",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":79,"prompt":89,"zipAvailable":90},[80,83,86],{"tool":81,"command":82},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill axiom-ui-testing",{"tool":84,"command":85},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill axiom-ui-testing",{"tool":87,"command":88},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill axiom-ui-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002FCharlesWiltgen\u002FAxiom\u002Faxiom-ui-testing\u002FSKILL.md",true,[92],{"path":93,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"_AIWF_IMPORT.json","REFERENCE","参考文档",361,"https:\u002F\u002Fgithub.com\u002FiDorgham\u002FWorkspace-Factory\u002Fblob\u002Fmaster\u002Ffactory\u002Flibrary\u002Fskills\u002Fgithub_imports\u002Fsast-configuration\u002F_AIWF_IMPORT.json",[99,109,119,128,134,141],{"skillNo":100,"name":101,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":105,"publishedAt":61},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[104],{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},[106,107,108],"model","model hierarchy","model hierarchy skill",{"skillNo":110,"name":111,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":115,"publishedAt":61},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[114],{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},[116,117,118],"MCP","zoom","zoom mcp",{"skillNo":120,"name":121,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":61},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[125,126,127,117],"sdk","zoom apps sdk","apps",{"skillNo":129,"name":130,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":61},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[130],{"skillNo":135,"name":136,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":140,"publishedAt":61},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[139],{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},[136],{"skillNo":142,"name":143,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":61},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[143]]