From 02fcbcc479e1b412a196aa6d1544a6103bacfb1a Mon Sep 17 00:00:00 2001 From: Dan Caseley Date: Sun, 3 Nov 2024 17:59:20 +0000 Subject: [PATCH 1/2] Fix off-by-one when specifying count with inputText (fixes #2122) --- .../androidTest/java/dev/mobile/maestro/MaestroDriverService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt b/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt index 083238f866..666f11899c 100644 --- a/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt +++ b/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt @@ -273,7 +273,7 @@ class Service( val charactersToErase = request.charactersToErase Log.d("Maestro", "Erasing text $charactersToErase") - for (i in 0..charactersToErase) { + for (i in 1..charactersToErase) { uiDevice.pressDelete() } From 9a71023baed8cb59621309f022ffa11a7e699c2e Mon Sep 17 00:00:00 2001 From: Dan Caseley Date: Sun, 3 Nov 2024 21:42:39 +0000 Subject: [PATCH 2/2] Add a short delay between backspace taps to ensure the correct number of taps occur Repeated tests show that the emulator can be slightly inconsistent and occasionally add an extra tap --- .../androidTest/java/dev/mobile/maestro/MaestroDriverService.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt b/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt index 666f11899c..6e530b7285 100644 --- a/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt +++ b/maestro-android/src/androidTest/java/dev/mobile/maestro/MaestroDriverService.kt @@ -275,6 +275,7 @@ class Service( for (i in 1..charactersToErase) { uiDevice.pressDelete() + Thread.sleep(50) // Attempt to ensure perfect count of taps on emulators } responseObserver.onNext(eraseAllTextResponse { })