xcuitest

Stabilize Swift 6 XCUITest flows with deterministic queries, waits, and failure screenshots.

Updated May 6, 2026
One-click install
npx skills add https://github.com/Roy-wonji/claude-config --skill xcuitest-roy-wonji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: xcuitest
Source: https://github.com/Roy-wonji/claude-config/tree/main/skills/apple-skills/skills/xcuitest
Command: npx skills add https://github.com/Roy-wonji/claude-config --skill xcuitest-roy-wonji

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves flaky and hard-to-maintain XCUITest UI test failures by giving practical, Swift 6-focused patterns for element querying, waiting, assertions, permissions handling, and diagnostics.

Core Features & Use Cases

  • Element querying and interaction patterns for XCUIApplication, XCUIElementQuery, and XCUIElement (including predicates and chained queries).
  • Reliable synchronization via wait strategies (waitForExistence, XCTWaiter, and key-path-based wait(for:toEqual:timeout:)), plus waiting for non-existence.
  • Test stability support for Swift 6 concurrency (@MainActor), launch arguments/environment configuration, system permission dialogs, and automatic screenshots on failure.
  • UI automation diagnostics including page-object style helpers and screenshot attachments extracted from .xcresult.

Quick Start

Use the xcuitest skill to write a Swift 6 XCUITest that reliably waits for a "Submit" button, taps it, asserts the "Done" state, and attaches a screenshot when the test fails.

Frequently Asked Questions about xcuitest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write stable iOS UI tests that stop failing randomly?

Stable iOS UI tests require deterministic element querying, resilient wait strategies, and proper synchronization using XCUITest APIs. Implementing robust patterns for element selection and applying Swift 6 concurrency rules eliminates random failures by using XCTWaiter and key-path waiting primitives to handle asynchronous UI loading.

How do I handle system permission dialogs in XCUITest?

Handle system permission dialogs in XCUITest by configuring XCUIApplication launch arguments and environment variables to pre-approve or disable alerts. This approach bypasses system-level interruptions during test execution, ensuring your automated UI tests run without manual intervention for consistent results.

What is the best way to wait for an element to appear in XCUITest?

The best way to wait for an element in XCUITest is using waitForExistence, XCTWaiter, or key-path-based wait primitives like wait(for:toEqual:timeout:). These synchronization methods ensure your tests pause reliably until UI elements are ready, preventing premature interaction failures.

Can I use XCUITest with Swift 6 concurrency and @MainActor?

Yes, XCUITest works with Swift 6 concurrency by applying @MainActor isolation to UI tests and using XCTest assertions suitable for main-actor Swift concurrency. This ensures thread-safe element interaction and query execution within your automated UI testing workflows.

How do I capture screenshots automatically when a UI test fails?

Capture screenshots automatically on UI test failure by attaching screenshot diagnostics to your XCUITest workflows. You can extract these visual attachments from the generated .xcresult bundles, providing immediate visual context to debug failed assertions and element states.

Why does my XCUIElement query fail to find the target UI component?

XCUIElement queries fail when lacking resilient synchronization or proper predicates. Using chained XCUIElementQuery patterns combined with explicit wait strategies ensures the UI hierarchy is fully loaded before querying, resolving missing element errors during test execution.