diff --git a/AutomatorServer/ios/AutomatorServerUITests/Automator.swift b/AutomatorServer/ios/AutomatorServerUITests/Automator.swift index f3cab979be..5415ffa928 100644 --- a/AutomatorServer/ios/AutomatorServerUITests/Automator.swift +++ b/AutomatorServer/ios/AutomatorServerUITests/Automator.swift @@ -110,30 +110,19 @@ class Automator { orPredicateWithSubpredicates: [textFieldPredicate, secureTextFieldPredicate] ) - 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)") + let textFields = app.descendants(matching: .any).matching(predicate) + let textFieldCount = textFields.allElementsBoundByIndex.count + Logger.shared.i("found \(textFields.count) text fields") + guard index < textFieldCount else { + throw PatrolError.viewNotExists("text field at index \(index)") } - element.firstMatch.forceTap() - element.firstMatch.typeText(data) + + let textField = textFields.element(boundBy: index) + textField.forceTap() + textField.typeText(data) } } - -// func enterText(_ data: String, by index: Int, inApp bundleId: String) async throws { -// try await runAction("entering text \(format: data) by index \(index)") { -// let app = try self.getApp(withBundleId: bundleId) -// let element = app.textFields.element(boundBy: index) -// -// let exists = element.waitForExistence(timeout: self.timeout) -// guard exists else { -// throw PatrolError.viewNotExists("text field at index \(index) in app \(format: bundleId)") -// } -// -// element.firstMatch.tap() -// element.firstMatch.typeText(data) -// } -// } // MARK: Services