Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding enableFlutterDriverExtension() disables keyboard on the app #417

Closed
ricky-bhatia opened this issue Feb 24, 2023 · 6 comments
Closed
Labels
question Further information is requested

Comments

@ricky-bhatia
Copy link

We are building our tests using appium and flutter driver to test our flutter app. The problem we are facing is after adding the enableFlutterDriverExtension() in main.dart file (as mentioned in the documentation), the soft keyboard on the phone stops showing up and doesn't allow any text entry in edit box widgets. This problem goes away once we remove the enableFlutterDriverExtension() statement. So, we are in a fix. Is there any solution to this problem?

@denysord88
Copy link

I just added ValueKey to the TextField key parameter in my POC Flutter app

const TextField(
    key: Key('_myTextField'),
),

and locating it with byValueKey method. It allows appium-flutter-driver type text there.

finder.byValueKey("_myTextField").sendKeys("12345");

But in our production Flutter app we are using ObjectKey instead of ValueKey and I don't know yet how to locate TextFields with appium-flutter-driver by ObjectKey. Investigating it now..

@denysord88
Copy link

Or in Flutter app add parameter enableTextEntryEmulation in enableFlutterDriverExtension() method
enableFlutterDriverExtension(enableTextEntryEmulation: false);

For my Appium framework it works this way:

getiOSDriver().context("NATIVE_APP");
getiOSDriver().findElements(By.xpath("//*[@label='']")).get(0).click();
getiOSDriver().findElements(By.xpath("//*[@label='']")).get(0).sendKeys("12345");
getiOSDriver().context("FLUTTER");

@zohaib304
Copy link

I have added the parameter enableFlutterDriverExtension(enableTextEntryEmulation: false);
The send_key('test"); doesn't work.

@denysord88

@denysord88
Copy link

I have added the parameter enableFlutterDriverExtension(enableTextEntryEmulation: false); The send_key('test"); doesn't work.

@denysord88

Are you using FlutterFinder class or IOSDriver to send a text? I guess enableTextEntryEmulation option disabling text input for FlutterFinder but enabling text input for Appium driver class IOSDriver

@ricky-bhatia
Copy link
Author

Or in Flutter app add parameter enableTextEntryEmulation in enableFlutterDriverExtension() method enableFlutterDriverExtension(enableTextEntryEmulation: false);

For my Appium framework it works this way:

getiOSDriver().context("NATIVE_APP");
getiOSDriver().findElements(By.xpath("//*[@label='']")).get(0).click();
getiOSDriver().findElements(By.xpath("//*[@label='']")).get(0).sendKeys("12345");
getiOSDriver().context("FLUTTER");

Thanks for the direction @denysord88 . I think I've got it working for my purpose. Here's what I did:

  1. I added this parameter enableFlutterDriverExtension(enableTextEntryEmulation: false) in the flutter app which enables underlying keyboard and text entry (as a default behavior)
  2. As @zohaib304 mentioned, with this the send_keys() does not work in the 'FLUTTER' context.
  3. Flutter driver provides this command setTextEntryEmulation which I used in the script as below
    driver.execute_script("flutter:setTextEntryEmulation", True)
    After this the send_keys() works fine in 'FLUTTER' context

@KazuCocoa KazuCocoa added the question Further information is requested label Aug 22, 2023
@KazuCocoa
Copy link
Member

Added a link to this ticket from https://github.com/appium/appium-flutter-driver/blob/main/README.md#troubleshooting (as a troubleshooting)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants