fix(runner): settle after InputText focus tap before key events

The focus tap raises the keyboard; with no settle the keyboard
animation races the erase/type key events on iOS, landing them in the
wrong field or dropping them. Wait for idle after a successful focus
tap, bounded by the run's idle timeout.
This commit is contained in:
pj committed 2026-06-06 00:33:56 +05:30
1 parent ff6513b89c
commit 6009adac48
2 files changed
+51 -20

No files matched your search

+13 -2
View File
@@ -227,7 +227,7 @@ func Run(ctx context.Context, options Options) (Summary, error) {
applySkipped := false
if nextErr == nil {
if err := applyAction(ctx, options.Driver, nextAction, tree); err != nil {
if err := applyAction(ctx, options.Driver, nextAction, tree, options.IdleTimeout); err != nil {
if isWDADrop(err) {
return summary, fmt.Errorf("step %d: iOS XCTest runner lost connection - known WDA startup flake, re-run the test: %w", stepIndex, err)
}
@@ -452,7 +452,7 @@ func settleForForeground(ctx context.Context, options Options) {
cancel()
}
func applyAction(ctx context.Context, drv driver.DeviceDriver, action verifier.Action, tree *hierarchy.Tree) error {
func applyAction(ctx context.Context, drv driver.DeviceDriver, action verifier.Action, tree *hierarchy.Tree, idleTimeout time.Duration) error {
switch action.Kind {
case verifier.ActionKindTap:
x, y, ok := resolveCoordinates(action, tree)
@@ -488,14 +488,25 @@ func applyAction(ctx context.Context, drv driver.DeviceDriver, action verifier.A
}
return drv.Swipe(ctx, fromX, fromY, toX, toY, duration)
case verifier.ActionKindInputText:
tapped := false
if x, y, ok := resolveCoordinates(action, tree); ok {
if err := drv.Tap(ctx, x, y); err != nil {
return err
}
tapped = true
} else if action.On != "" {
if err := drv.TapSelector(ctx, action.On); err != nil {
return err
}
tapped = true
}
// The focus tap raises the keyboard. Settle before sending key
// events so the keyboard animation cannot race them into the wrong
// field (or drop them entirely).
if tapped {
idleCtx, idleCancel := context.WithTimeout(ctx, idleTimeout)
_ = drv.WaitForIdle(idleCtx, idleTimeout)
idleCancel()
}
// InputText replaces the field's content: erase what the target
// holds before typing. Appending instead lets repeated draws grow