Open bartekpacia opened 2 years ago
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
.
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:
Another idea worth trying out: use UiAutomation.executeShellCommand
instead of UiDevice.executeShellCommand
We could see how Maestro by mobile.dev does this.
See:
We could differentiate between host services and local services (ADB does it).
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.
We lost this feature in 1.0 :)
Do you have any news about this please ?
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