Last active
October 14, 2022 07:04
-
-
Save bartekpacia/8cea37646bc6197a4bbdf6fbcbb5b83e to your computer and use it in GitHub Desktop.
Exploring what's possible with NSPredicate.
This file contains 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 | |
final class LandmarksUITests: XCTestCase { | |
let app = XCUIApplication() | |
override func setUpWithError() throws { | |
continueAfterFailure = false | |
app.launch() | |
} | |
func testNormal() throws { | |
let element = app.descendants(matching: .any)["Turtle Rock"] | |
element.firstMatch.tap() | |
} | |
func testPredicates() throws { | |
let element = app.descendants(matching: .any).matching(NSPredicate(format: "label == 'Turtle Rock'")) | |
element.firstMatch.tap() | |
} | |
func testTextFieldNormal() throws { | |
let element = app.textFields["username"] | |
element.firstMatch.tap() | |
element.firstMatch.typeText("hello") | |
} | |
func testStaticTextPredicate() throws { | |
let element = app.descendants(matching: .any).element(matching: (NSPredicate(format: "label == 'Turtle Rock'"))) | |
element.firstMatch.tap() | |
} | |
func testTextFieldNormal2() throws { | |
let element = app.descendants(matching: .any).element(matching: (NSPredicate(format: "placeholderValue == 'username'"))) | |
element.firstMatch.tap() | |
element.firstMatch.typeText("hello") | |
} | |
func testTextFieldNormal3() throws { | |
// see https://developer.apple.com/documentation/xctest/xcuielementtype/xcuielementtypetextfield | |
let element = app.descendants(matching: .any).element(matching: (NSPredicate(format: "elementType == 49"))) | |
element.firstMatch.tap() | |
element.firstMatch.typeText("hello") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment