I’ve already explained how deep links can help with in-app navigation when we have some test automation utilizing Espresso framework. But the point is that such approach suites only for one platform - Android.
Mobile test automation can be done using different tools and frameworks. Tool selection should be based on the app itself, tech stack for app development, whether app is cross-platform and lots of other factors. If we are talking about test automation in terms of cross-platform app it is fair to consider appium to be one of the best fits for this purpose.
So let’s address one more example how to open deep links on real devices using Appium.
Input
Deep links on Android can be easily opened just with
driver.execute(
'mobile:deepLink',
{
url: "<deep-link-url>",
package: "<package-name>"
}
);
For iOS, additional steps should be taken. We need to use Safari browser to open deep links.
As far as ‘open deep link’ implementation differs for iOS and Android let’s consider a common solution.
Solution
I prefer writing code that is highly readable, so you don’t need to spend a lot of time figuring out what’s going on in the particular test or method.
That’s why I structured my implementation in this way, having common public method
public void openDeepLinkUrl(String url) {...}
to call withing test script.
And we have platform specific implementations to open deep links.
For iOS:
and for Android:
Then we can have a cross-platform method:
That’s it.
Full code example can be found here.