Skip to content

Commit

Permalink
finally, use predicates correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Oct 14, 2022
1 parent 4ec9868 commit 3f55810
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions AutomatorServer/ios/AutomatorServerUITests/Automator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,16 @@ class Automator {
try await runAction("entering text \(format: data) by index \(index)") {
let app = try self.getApp(withBundleId: bundleId)

let textFieldPredicate = NSPredicate(format: "elementType == 49")
let secureTextFieldPredicate = NSPredicate(format: "elementType == 50")
let predicate = NSCompoundPredicate(
orPredicateWithSubpredicates: [textFieldPredicate, secureTextFieldPredicate]
)

let textFieldPredicate = NSPredicate(format: "elementType == 'XCUIElementTypeTextField AND exists == 1'")
//let secureTextFieldPredicate = NSPredicate(format: "elementType == 'XCUIElementTypeSecureTextField'")
//let existsPredicate = NSPredicate(format: "exists == 1")
// let predicate = NSCompoundPredicate(
// orPredicateWithSubpredicates: [
// textFieldPredicate,
// //secureTextFieldPredicate
// ]
// )

let element = app.descendants(matching: .any).matching(textFieldPredicate)
// let exists = element.waitForExistence(timeout: self.timeout)
// guard exists else {
// throw PatrolError.viewNotExists("text field at index \(index) in app \(format: bundleId)")
// }
let elements = app.descendants(matching: .any).matching(predicate).allElementsBoundByIndex
guard let element = self.waitForAnyElement(elements: elements, timeout: self.timeout) else {
throw PatrolError.viewNotExists("text field at index \(index) in app \(format: bundleId)")
}

element.firstMatch.forceTap()
element.firstMatch.typeText(data)
Expand Down

0 comments on commit 3f55810

Please sign in to comment.