https://github.com/0xwdg/xcuitesthelper
XCUITestHelper helps you writing UI tests within SwiftUI. It provides a set of useful extensions on XCUIApplication, XCUIElement and XCUIElementQuery to make your tests more readable and easier to maintain.
https://github.com/0xwdg/xcuitesthelper
0xwdg hacktoberfest spm swift swiftlang uitest xctest xcuitext
Last synced: about 1 month ago
JSON representation
XCUITestHelper helps you writing UI tests within SwiftUI. It provides a set of useful extensions on XCUIApplication, XCUIElement and XCUIElementQuery to make your tests more readable and easier to maintain.
- Host: GitHub
- URL: https://github.com/0xwdg/xcuitesthelper
- Owner: 0xWDG
- License: mit
- Created: 2024-08-08T19:54:32.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-02-20T20:17:09.000Z (4 months ago)
- Last Synced: 2025-05-02T09:18:18.017Z (about 1 month ago)
- Topics: 0xwdg, hacktoberfest, spm, swift, swiftlang, uitest, xctest, xcuitext
- Language: Swift
- Homepage: https://0xwdg.github.io/XCUITestHelper/
- Size: 312 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# XCUITestHelper
XCUITestHelper helps you writing UI tests within SwiftUI. It provides a set of useful extensions on [XCUIApplication](Sources/XCUITestHelper/XCUIApplication.swift), [XCUIElement](Sources/XCUITestHelper/XCUIElement.swift) and [XCUIElementQuery](Sources/XCUITestHelper/XCUIElementQuery.swift) to make your tests more readable and easier to maintain.
[](https://swiftpackageindex.com/0xWDG/XCUITestHelper)
[](https://swiftpackageindex.com/0xWDG/XCUITestHelper)
[](https://swift.org/package-manager)
## Requirements
- Swift 5.9+ (Xcode 15+)
- iOS 13+, macOS 10.15+## Installation (Pakage.swift)
```swift
dependencies: [
.package(url: "https://github.com/0xWDG/XCUITestHelper.git", branch: "main"),
],
targets: [
.target(name: "MyTarget", dependencies: [
.product(name: "XCUITestHelper", package: "XCUITestHelper"),
]),
]
```## Installation (Xcode)
1. In Xcode, open your project and navigate to **File** โ **Swift Packages** โ **Add Package Dependency...**
2. Paste the repository URL (`https://github.com/0xWDG/XCUITestHelper`) and click **Next**.
3. Make sure you add it to the **UITest target**!
4. Click **Finish**.## Usage / Examples
```swift
import XCTest
import XCUITestHelperfinal class MyAppUITests: XCTestCase {
override func setUpWithError() throws {
continueAfterFailure = false
}func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()// * Set the app language to English.
app.setLanguage(to: .english)
// Do this before launching the app.
app.launch()// * `Wait` for 1 second to continue
app.wait(for: 1)// * Tap a `random` cell in a collection view.
// Random works with any kind of element, not just buttons.
app.collectionViews.buttons.random.tap()// * Go back to previous screen (NavigationView)
app.navigateBack()// * Tap on the last button
app.buttons.lastMatch.tap()// * Tap on the second button
app.buttons[1].tap()// * Type something, and then clear it.
let textfield = app.searchFields.firstMatch
app.type(in: textfield, text: "a", action: .clear)
}
}
```## Contact
๐ฆ [@0xWDG](https://bsky.app/profile/0xWDG.bsky.social)
๐ [mastodon.social/@0xWDG](https://mastodon.social/@0xWDG)
๐ฆ [@0xWDG](https://x.com/0xWDG)
๐งต [@0xWDG](https://www.threads.net/@0xWDG)
๐ [wesleydegroot.nl](https://wesleydegroot.nl)
๐ค [Discord](https://discordapp.com/users/918438083861573692)Interested learning more about Swift? [Check out my blog](https://wesleydegroot.nl/blog/).