appium / appium-flutter-driver

Appium Flutter Driver is a test automation tool for Flutter apps on multiple platforms/OSes. Appium Flutter Driver is part of the Appium mobile test automation tool maintained by community
MIT License
454 stars 183 forks source link

Some Android keyevents are not working with Flutter app #623

Open pprettytony opened 10 months ago

pprettytony commented 10 months ago

Stack:

Android 12.0 (emulator)
Maven 3.9.1
Java 11
MacOS 13.0
Appium 2.0.0-beta.52
Java Client 8.3.0
Selenium Java 4.8.0
TestNG 7.7.0

Description:

Since we have no displayed keyboard in the app with flutter_driver enabled, I found that it's a problem to "simulate" pressing on Enter button, there is no reaction on any of my action to the emulator/app. BUT, there is no problem with Delete button. After some additional investigation I found that Enter, A-Z, 0-9 are not working at all, but Delete, Escape, Tab are working properly (I didn't check all keyevents that Android have, but here the list of them). I tried different ways to interact with Enter button:

Map<String, Object> cmd = ImmutableMap.of("command", "input", "args", List.of("keyevent", 66));
((AndroidDriver)driver).executeScript("mobile: shell", cmd);

or

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.ENTER));

or directly in terminal

adb shell input keyevent 66

All these methods perform exact the same action, as far as I understood, but with no result in case of Enter, A-Z, 0-9 buttons. If I try to replace Enter button with Delete - everything works great.

I also tried to use Selenium sequence:

final KeyInput keyboard = new KeyInput("keyboard");
Sequence sequence = new Sequence(keyboard,  0);
sequence.addAction(keyboard.createKeyDown(Keys.ENTER.getCodePoint()));
sequence.addAction(keyboard.createKeyUp(Keys.ENTER.getCodePoint()));
driver.perform(Collections.singleton(sequence));

As a result, I have the same behaviour, Enter isn't working, but Delete is working properly (Backspace is working too). I even tried to use a sendKeys (or flutter:enterText) methods:

searchField.sendKeys("\n");
searchField.sendKeys("\uE006"); RETURN keyCode
searchField.sendKeys("\uE007"); ENTER keyCode

or 

((AndroidDriver) driver).context("FLUTTER");
driver.executeScript("flutter:enterText", "\n");
driver.executeScript("flutter:enterText", "\uE006");
driver.executeScript("flutter:enterText", "\uE007");
((AndroidDriver) driver).context("NATIVE_APP");

No results from these actions as well. All actions were performed with EditText element in NATIVE_APP context (except last Flutter action)

Question: Is it possible to simulate tapping/clicking on Enter, A-Z, 0-9 buttons with flutter_driver enabled?

pranjali-student commented 2 months ago

did you get any answer ? im stuck in a similar way

nilotavaresneto commented 2 months ago

I'm stuck in the same situation. Please someone help.

dan-oliveiraa commented 2 months ago

Did you get any answer ? I'm stuck in the same situation

isabella-laporte commented 2 months ago

I am having the same issue. Can someone help us? D:

ATMarcelino commented 2 months ago

Please, can anyone help me?? I have the same problem!

Seems like a known issue. Someone must have a solution...