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

Close keyboard if opened #66

Open
bartekpacia opened this issue Jun 14, 2022 · 7 comments
Open

Close keyboard if opened #66

bartekpacia opened this issue Jun 14, 2022 · 7 comments
Labels
feature New feature request P2 Issues not at the top of the work list package: patrol Related to the patrol package (native automation, test bundling) platform: android Android is affected platform: ios iOS is affected

Comments

@bartekpacia
Copy link
Contributor

bartekpacia commented Jun 14, 2022

There's no easy way to do this using UiAutomator.

There's a hack though. An ugly one, but it works it works only through ADB.

Here's the link

@bartekpacia bartekpacia self-assigned this Jun 14, 2022
@bartekpacia
Copy link
Contributor Author

bartekpacia commented Jun 14, 2022

We cannot call adb shell dumpsys from the app (this also applies to test instrumentation), see this.

An (overengineered?) workaround could be running some second simple "maestro daemon" process on the host machine.

Edit: After giving it some thought, I think that maestro_cli could have a simple HTTP (or gRPC, now that we've migrated to gRPC) server in itself. Then we could make requests from the integration test to the CLI, which runs on the host machine and has full access to powerful debugging tools like adb and idb.

Example

Take this code snippet:

import 'package:maestro_test/maestro_test.dart';

Automator.init(verbose: true);
final automator = Automator.instance;

// ...

Automator.isKeyboardOpened()

would make a HTTP request not to the connected Android device, but to the maestro daemon instead. Then the maestro deamon would be able to adb shell dumpsys.

Pros:

  • we have more power

    There are probably more commands that can only be executed through ADB and not by the instrumentation. This needs
    more investigation.

Cons:

  • complexity, more stuff to debug and maintain

@bartekpacia bartekpacia removed their assignment Jun 14, 2022
@bartekpacia
Copy link
Contributor Author

Another idea worth trying out: use UiAutomation.executeShellCommand instead of UiDevice.executeShellCommand

@bartekpacia bartekpacia changed the title Android – close keyboard if opened Close keyboard if opened Aug 1, 2022
@bartekpacia bartekpacia added the platform: android Android is affected label Aug 1, 2022
@bartekpacia bartekpacia added package: patrol Related to the patrol package (native automation, test bundling) feature New feature request labels Sep 13, 2022
@bartekpacia
Copy link
Contributor Author

We could see how Maestro by mobile.dev does this.

See:

@bartekpacia
Copy link
Contributor Author

We could differentiate between host services and local services (ADB does it).

@bartekpacia
Copy link
Contributor Author

Important update

In #593 we've got a powerful new capability of acting as a host. This means we're able to use adb and programmatically hide keyboard.

Here's how Maestro does this – the hideKeyboard() method.

@bartekpacia
Copy link
Contributor Author

bartekpacia commented Feb 18, 2023

We lost this feature in 1.0 :)

@jBorkowska jBorkowska added platform: ios iOS is affected P1 High-priority issues at the top of the work list labels Nov 17, 2023
@jBorkowska jBorkowska added P2 Issues not at the top of the work list and removed P1 High-priority issues at the top of the work list labels Nov 27, 2023
@yacineblr
Copy link

Do you have any news about this please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request P2 Issues not at the top of the work list package: patrol Related to the patrol package (native automation, test bundling) platform: android Android is affected platform: ios iOS is affected
Projects
None yet
Development

No branches or pull requests

3 participants