Last active
December 8, 2024 21:17
-
-
Save technotariat/c643641c9f02670d87342959dad06a34 to your computer and use it in GitHub Desktop.
XCUITest with Page Object Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import XCTest | |
| class ExamplePOM { | |
| let app: XCUIApplication | |
| init(app: XCUIApplication) { | |
| self.app = app | |
| } | |
| func pressTheButton() { | |
| // perform the action | |
| self.app.buttons["Button to Press"].tap() | |
| // check the result of doing the action | |
| XCTAssertTrue(app.staticTexts["Button pressed"].exists) | |
| } | |
| } | |
| final class ATest: XCTestCase { | |
| var app: XCUIApplication! | |
| var examplePom: ExamplePOM! | |
| override func setUpWithError() throws { | |
| continueAfterFailure = false | |
| app = XCUIApplication() | |
| app.launch() | |
| examplePom = ExamplePOM(app: app) | |
| } | |
| @MainActor | |
| func testAThing() { | |
| examplePom.pressTheButton() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment