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

Inability to retrieve current application being run in interaction hook #99

Open
Mystaras opened this issue Nov 24, 2022 · 0 comments
Open

Comments

@Mystaras
Copy link

The example that explains how to fetch the application data (APK name/URL) of the current run in examples/monkeyplayer/Scripts/interaction.py uses get_experiment(). Which, depending on the experiment's configuration, either returns the next run or a random new run, but not the current run.

Hence, there is currently no way to identify the current run and more importantly the current application. This is especially useful when one has custom Monkey Runner or ADB interactions for each application.

Currently none of the hooks of the Experiment class propagated the path and run parameters to the user scripts. Only Device and sometimes self (the experiment object itself) are propagated.

Whether the experiment is for a Native or a Web application, the respective super Experiment function will always be called with the run, path parameters. Since path contains the APK name in the case of a Native experiment, or, the URL in the case of a web experiment. It is the key variable in identifying the current application in the user scripts. Run is not that crucial as it is the run number which should be useful only for debugging, yet it could be useful in some context as after_last_run is currently not implemented.

The two possible mitigations are the following:

  1. Instead of unpacking, propagate the entire current_run dictionary through the control flow of the program. And finally propagate it to the user scripts. Which will require heavily modifying the logic of the code throughout the entire application.

  2. Keep the current structure and ensure all hook functions in Experiment.py (before_experiment, before_run, after_launch, interaction, before_close, after_run, after_experiment) propagate the parameters to the user scripts: self.scripts.run('HOOK', device, self, path, run, *args, **kwargs).

The resulting fix might require changing most of the example scripts and might also break compatibility with past experiments as the user scripts will receive different parameters. But with the suggested parameter order proposed in 2., only before_close and after_launch will be influenced. Of which the two extra parameters are contained in the Device parameter itself.

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

No branches or pull requests

1 participant