Skip to content

Commit

Permalink
Move default tap coords for enterText other place
Browse files Browse the repository at this point in the history
  • Loading branch information
piotruela committed Oct 1, 2024
1 parent d2a3319 commit 24e26f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -924,15 +924,16 @@
}

// MARK: Private stuff
private func clearAndEnterText(data: String, element: XCUIElement, dx: CGFloat, dy: CGFloat) {
private func clearAndEnterText(data: String, element: XCUIElement, dx: CGFloat?, dy: CGFloat?) {
let currentValue = element.value as? String
var delete: String = ""
if let value = currentValue {
delete = String(repeating: XCUIKeyboardKey.delete.rawValue, count: value.count)
}

// We need to tap at the end of the field to ensure the cursor is at the end
let coordinate = element.coordinate(withNormalizedOffset: CGVector(dx: dx, dy: dy))
// By default we tap at the end of the field to ensure the cursor is at the end
let coordinate = element.coordinate(
withNormalizedOffset: CGVector(dx: dx ?? 0.9, dy: dy ?? 0.9))
coordinate.tap()

element.typeText(delete + data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
inApp: request.appId,
dismissKeyboard: request.keyboardBehavior == .showAndDismiss,
withTimeout: request.timeoutMillis.map { TimeInterval($0 / 1000) },
dx: request.dx ?? 0.9,
dy: request.dy ?? 0.9
dx: request.dx,
dy: request.dy
)
} else if let selector = request.selector {
try automator.enterText(
Expand All @@ -165,8 +165,8 @@
inApp: request.appId,
dismissKeyboard: request.keyboardBehavior == .showAndDismiss,
withTimeout: request.timeoutMillis.map { TimeInterval($0 / 1000) },
dx: request.dx ?? 0.9,
dy: request.dy ?? 0.9
dx: request.dx,
dy: request.dy
)
} else if let iosSelector = request.iosSelector {
try automator.enterText(
Expand Down

0 comments on commit 24e26f7

Please sign in to comment.