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

Add shell to PatrolIntegrationTester, or ability to execute code on testing machine #2386

Open
Sevastyan opened this issue Oct 30, 2024 · 1 comment
Assignees
Labels
feature New feature request package: patrol Related to the patrol package (native automation, test bundling)

Comments

@Sevastyan
Copy link

Use case

I am writing patrol test to test my Flutter app on Android emulator on my machine. I want to be able to run terminal commands on my host machine during the patrol test (inside the PatrolTesterCallback).

This feature request is indeed related to the problem I am having, however the feature will serve a much wider variety of cases than described shortly.

So, the problem is that I cannot trigger Android's flow for handling URLs of Instant Apps. When testing manually, I usually fire this terminal command:

adb shell 'am start -a android.intent.action.VIEW -d "https://..." com.my.applicationId'

this brings up this system UI:

And then, when testing manually, I click "OPEN APP", which opens Android Instant App, from which I download my full app and get to testing further.

The adb command above is not the only one I wish to be able to run from within the patrol test. I also want to generate the URL during the test, and for this I have a nifty CLI command on my machine (it contacts my server to get me the URL).

To sum up, I want to start my patrol test by running a few terminal commands (executing them on my host machine), and then start using patrol's finders to assert what is shown on the emulator's screen.


What I have tried:

There is already a native openUrl method provided by patrol. However, it never opens the Android's UI as in the picture above - it simply opens the browser (not even my app, which actually handles the URL nicely). openUrl will only open my app, if the URL schema is a custom schema that my app supports. I mean, my app support both "https://" and "mycustomapp" shemas. But with patrol I am not able to test "https" schema, as it always opens the browser. This, obviously, makes it impossible to test the real user flow - user clicking on the URL, user making a decision to continue viewing the URL in the Instant App, user interacting with Instant App, user downloading the full app, and user interacting with the full app.

Proposal

void main() {
  patrolTest(
    'My test.',
    ($) async {
      final result = $.host.run('command', ['option', 'value']); // akin to Process.run on the host
      // use result...
    },
  );
}
@jBorkowska jBorkowska self-assigned this Oct 31, 2024
@jBorkowska jBorkowska added feature New feature request package: patrol Related to the patrol package (native automation, test bundling) labels Oct 31, 2024
@bartekpacia
Copy link
Contributor

this was implemented in #630 but then removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request package: patrol Related to the patrol package (native automation, test bundling)
Projects
None yet
Development

No branches or pull requests

4 participants