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

Testing deep linking #556

Closed
SebastianKlaiber opened this issue Nov 3, 2022 · 13 comments · Fixed by #2219
Closed

Testing deep linking #556

SebastianKlaiber opened this issue Nov 3, 2022 · 13 comments · Fixed by #2219
Assignees
Labels
feature New feature request package: patrol Related to the patrol package (native automation, test bundling)

Comments

@SebastianKlaiber
Copy link

Hi,

is there a way to test deep links with patrol? I've only found the open App method, but I want to specify a URL and check if my app opens and navigates to the correct page.

e.g.: await $.native.openLink(link: 'http://www.example.com/passwordrest');

@bartekpacia
Copy link
Contributor

bartekpacia commented Nov 3, 2022

Hi Sebastian, thanks for creating this issue! Looks like a cool feature to have.

Let me clarify a bit: what would the openLink() method do? Would it call adb? Like this:

$ adb shell am start -a android.intent.action.VIEW -d "example://gizmos" com.my.app

Or maybe you have another idea on how this could work? If yes I'd be happy if you shared them:)

Also, the solution has to be cross-platform solution (both Android and iOS).

@bartekpacia bartekpacia added feature New feature request package: patrol Related to the patrol package (native automation, test bundling) labels Nov 3, 2022
@SebastianKlaiber
Copy link
Author

SebastianKlaiber commented Nov 3, 2022

Yes, exactly it should call adb for android and for ios simctl openurl booted "example://gizmos"

@bartekpacia
Copy link
Contributor

bartekpacia commented Nov 15, 2022

Here's how Maestro does this – the openLink() method:

Docs.

@bartekpacia
Copy link
Contributor

Dear testers: @jBorkowska, @fylyppo, @Kendru98, @zoskar, and our dear external user @lmlikota – please chip in :)

  • What are the most common use cases of testing app links?
  • How would you like the API to look like?

The simplest version could be:

class HostAutomator {
  Future<void> openLink(String url);
}

So await $.host.openLink("example://gizmos") would result in adb shell am start -d "example://gizmos". But that's kinda limiting because, as you could see in a comment above, adb supports more options (docs here)

Screenshot 2022-11-17 at 1 12 10 PM

@bartekpacia
Copy link
Contributor

@SebastianKlaiber

Yes, exactly it should call adb for android and for ios simctl openurl booted "example://gizmos"

And what about physical iOS devices? Do you have some idea?

@jBorkowska
Copy link
Collaborator

If we're talking about e2e testing, I don't see a use case for that - user never provides a literal link as a deeplink.
If we're talking about cases, when we can't perform the action that opens a deeplink (eg. it requires real payment), then I understand - but again, I don't know how those links work, but if providing a link is sufficient from technical perspective, so is for us.

Most common cases:

  • opening mail app and opening app by link in email (something like account confirmation)
  • opening Play store or App store
  • opening app as a redirection from browser
  • maybe something else?

@bartekpacia
Copy link
Contributor

It should be possible to run ActivityManager from Java/Kotlin code within the app.

@lhimo
Copy link

lhimo commented Dec 13, 2022

We would need to add this to adb shell commands in order to test dynamic links:

-W -a android.intent.action.VIEW

@Sevastyan
Copy link

The proper way to test it for Android via adb:

adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://your.domain.com/path?param1=1%26param2=2"

The above tries to open some app to show the content of the link. It may be some app that is already installed on a device, or it may be a browser, or it may be an Instant App.

So, in general, the feature should simulate OS's action for following a link on a device under test. Is this something in scope for patrol even?

@jBorkowska There is definitely a test case for e2e testing in regards to deep links. Or, I should rather refer to them as "App Links" (in Android lingo). The test case is:

  1. Open default email client on a mobile device (let's say Gmail app).
  2. Open the latest email that contains the link (let's say it's invitation for onboarding to the product under test).
  3. Click the link in that email.
  4. Check that the user sees a screen from the Instant App, or full installable app (or a webpage even).

Granted, the journey doesn't start within the app under test, I can see why this may be outside of scope for patrol though. But damn it would be so nice to have.

There is another example "somewhat from within the app":

  1. Have the app under test open in the background.
  2. Click the link in your email.
  3. Ensure that the app under test comes back to foreground and displays a correct screen that corresponds to the link.

@PawlikMichal25
Copy link

My 2 cents:
Of course we can already write tests by passing a link directly to App in Dart, but being able to write E2E tests would be much better because that would also cover:

  • native configurations
  • whether OS verifies that app can handle the deep links (which is like OS + app + files on your website/domain, so can be broken by Web/BE devs)
  • covers both app being launched and already opened

@Sevastyan
Copy link

@bartekpacia I'd like to inquire about bringing back host functionality, so that I can run $.host.runProcess('adb shell...'). Is it in the plans? Having the ability to test deep links is crucial for my project.

@bartekpacia
Copy link
Contributor

Hi @Sevastyan – I no longer work on Patrol, so I can't answer. But if such functionality was re-introduced, it would only work in places where you can directly run patrol_cli. This excludes "device farm" services like Firebase Test Lab, emulator.wtf, or BrowserStack. You'd have to use a "full-blown" CI service like GitHub Actions or CircleCI. Ultimately it's all about tradeoffs.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature request package: patrol Related to the patrol package (native automation, test bundling)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants