How to Test Deep Links on Android & iOS devices
On This Page What are Deep Links?What Happens when a
How to Test Deep Links on Android & amp; iOS devices
A deep link is a hyperlink that directs users to a specific page or content within an application kinda than but the homepage.
Deeplink testing verifies deep links ’ functionality within a software covering or site.
Deeplink testers can alleviate this by checking whether the deep linkup act correctly and redirect users to the intended destination. They screen them across different operate systems, device, and browsers to ensure compatibility.
It also involves control their functionality in different scenarios, such as when the app runs in the background or when the user is not logged in.
This article delves deeper into testing deep links on Android and iOS devices.
What are Deep Links?
Deep link is a technology that launches an app and opens a specific page once the exploiter clicks a URL on a web page or another app.
- Implementing deep links is an exciting way to heighten the exploiter experience by seamlessly let users to access the specific page without interruption.
- Deeplinks are commonly apply in mobile apps, social media platforms, and e-commerce websites to provide users with a direct and efficient way to accession specific content or lineament. As a result of this, user date and retention growth significantly.
Let ’ s understand deep tie-in with a simple model: When look the keyword “ Floral Wallpaper ” on Google, # floralwallpaper of Instagram appears as a prevue among the search answer.
As the user clicks on the Search Result link, it opens the event page in the Instagram app that is already instal on the device. This is where Deep Linking comes into play, where the user gets redirect from the web search event page to the Instagram Application.
The intent hither is to allow the exploiter to access the # floralwallpaper on the Instagram app seamlessly instead of opening it on the website. This enriches the overall user experience, allow user to access the app features seamlessly.
However, considering security aspects, Deep Links are easily exploitable if not used with due diligence for sanction purposes. Sometimes these deep links contain sensitive datum, and when not tested decently, they might let a malicious app to address the deep tie alternatively of the legitimate app. In such scenarios,Deep Link Testingplay a crucial role in meliorate the overall caliber and security of the product.
What Happens when a User Clicks a Deep Link
Deep tie is a URL that voyage the user from the web to a specific page in a given app. When the user tick a deep link, Android performs either of the following action:
- Opens the mandatory app in the user & # 8217; s device that can handle the link if the app is already available on the device.
- If the required app isn ’ t available, it opens the sole app that can handle the linkup or opens PlayStore, from which the user can download the required app.
- In instance when multiple apps can handle the URL, it opens a dialog allowing the exploiter to select one app from the yield list of compatible apps to open the link.
Deeplink testers ensure that deeplinks are fittingly coded, redirecting users to the right content and functioning as intended. This role is life-sustaining for applications and websites that rely on it, such as e-commerce platforms, societal media apps, and intelligence websites.
Why are Deep Links important?
Deep Linking makes any transition between web and apps hassle-free and smooth for users. Given the seamless user experience, it helps advertisers get a better chance of converting exploiter into customers.
- Retaining users is the key focus of deep linking.
- It is ofttimes employ for re-engaging users and is a key component of retargeting campaigns.
- Since it gives a seamless transition from a web link to an app, deep linking derogate the chances of user not accessing the page redirect by the campaign URL.
Components of a Deep Link
Deep Link consists of various components, but like any URL. Let ’ s understand the components of a deep link with an model. Consider a dummy deep linkhttps: //www.browserstack.com/test/code=abcd. It can be categorized into:
- https & # 8211;It name the protocol habituate to accession the resource on the cyberspace.
- www.browserstack.com & # 8211;It is the legion, i.e. the domain name or reference of the web server that is being accessed.
- /test & # 8211;The path specifies a particular page of the content.
- code & # 8211;The inquiry parameter to extract from intents in your address.abcdis the value of the argument.
Types of Deep Links
Deep Links can be sort as Default, Deferred, and Contextual deep linkup.
1. Default Deep Links
These deep links only direct users to the command app if it ’ s already instal on the device. In case, where the app is not installed, the linkup is unable to attain the endpoint of an app, and thusly an error message is displayed.
2. Deferred Deep Links
These deep tie are more complex than default deep linkup. They can direct users to the App if it is available on the device. In suit the app is not available on the gimmick, it target the users to Play Store or to another location, such as the app ’ s website for more information, and then open the original page that the user was aim to.
3. Contextual Deep Linking
Contextual deep relate involves links that ostensibly cater additional welfare. Contextual deep links are the default or deferred deep tie with added parameters. Contextual deep link don ’ t exist severally since the other argument are manually append. The marketers themselves can add the argument. Such contextual deep tie help in tag the traffic source of the campaign.
For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.
How to test Deep Links on Android?
Testing Deep Links are important to ensure a high-end user experience. Functioning of Deep Links directly affect user engagement; that is why screen has to be performed diligently.
For getting precise results, considering real user conditions is a must. Thus, it is commend to perform Deep Link Testing on real device. However, buying and maintaining real device is costly. Hence expend real device cloud, like BrowserStack, can be a great way to test deep relate under real user weather on 3500+ browser device combination.
Following are the different ways of examination deeplink Android:
Using Android Debug Bridge
By using Android Debug Bridge (ADB) shell commands one can quiz the deep link flowing. It is used to verify if the link navigates to the right section of your app.
Open the terminal and enter the following command:
adb shell am start -W -a android.intent.action.VIEW -d `` your deep connection url ''
This dictation starts the ADB carapace with the VIEW activeness and specifies the deep tie-in URL to be tested.
Using Appium Driver
The below example show two ways of prove that the logged-in experience works correctly: 1st by navigating the login UI with Appium, and so by using the deep linking trick trace in this edition.
import io.appium.java_client.AppiumDriver; import io.appium.java_client.MobileBy; import io.appium.java_client.android.AndroidDriver; import java.io.IOException; import java.net.URL; significance org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; meaning org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; @ RunWith (JUnit4.class) public class Appium_Deep_Linking {individual String APP_ANDROID = `` https: //github.com/cloudgrey-io/the-app/releases/download/v1.2.1/TheApp-v1.2.1.apk ''; private String AUTH_USER = `` alice ''; private String AUTH_PASS = `` mypassword ''; @ Test public void testLoginSlowAndroid () throws IOException {AndroidModel model = new AndroidModel (); AndroidDriver driver = new AndroidDriver (new URL (`` http: //localhost:4723/wd/hub ''), model.caps); runStepByStepTest (driver, framework);} private void runStepByStepTest (AppiumDriver driver, Model framework) {WebDriverWait wait = new WebDriverWait (driver, 10); try {wait.until (ExpectedConditions.presenceOfElementLocated (model.loginScreen)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (model.username)) .sendKeys (AUTH_USER); wait.until (ExpectedConditions.presenceOfElementLocated (model.password)) .sendKeys (AUTH_PASS); wait.until (ExpectedConditions.presenceOfElementLocated (model.loginBtn)) .click (); wait.until (ExpectedConditions.presenceOfElementLocated (model.getLoggedInBy (AUTH_USER)));} finally {driver.quit ();}} @ Test public void testDeepLinkForDirectNavAndroid () shed IOException {AndroidModel model = new AndroidModel (); AndroidDriver driver = new AndroidDriver (new URL (`` http: //localhost:4723/wd/hub ''), model.caps); runDeepLinkTest (driver, poser);} individual void runDeepLinkTest (AppiumDriver driver, Model model) {WebDriverWait wait = new WebDriverWait (driver, 10); try {driver.get (`` theapp: //login/ '' + AUTH_USER + `` / '' + AUTH_PASS); wait.until (ExpectedConditions.presenceOfElementLocated (model.getLoggedInBy (AUTH_USER)));} lastly {driver.quit ();}} individual abstract class Model {public By loginScreen = MobileBy.AccessibilityId (`` Login Screen ''); public By loginBtn = MobileBy.AccessibilityId (`` loginBtn ''); public By username; public By password; public DesiredCapabilities caps; abstract By getLoggedInBy (String username);}} private form AndroidModel extends Model {AndroidModel () {username = MobileBy.AccessibilityId (`` username ''); password = MobileBy.AccessibilityId (`` password ''); caps = new DesiredCapabilities (); caps.setCapability (`` platformName '', `` Android ''); caps.setCapability (`` deviceName '', `` Android Emulator ''); caps.setCapability (`` app '', APP_ANDROID); caps.setCapability (`` automationName '', `` UiAutomator2 '');} public By getLoggedInBy (String username) {return By.xpath (`` //android.widget.TextView [@ text=\ '' You are logged in as `` + username + `` \ ''] '');}}}Using ActivityTestRule and Espresso Intent
Follow the steps mentioned below to test Deep Links:
Step 1Start with an activity rule
@ Rule public ActivityTestRule & lt; YourAppMainActivity & gt; mActivityRule = new ActivityTestRule & lt; & gt; (YourAppMainActivity.class, true, false);
Step 2Parse the URI (Uniform Resource Identifier) from the link and revert the intent
String uri = `` http: //your_deep_link_from_gmail ''; private Intent getDeepLinkIntent (String uri) {Intent intent = new Intent (Intent.ACTION_VIEW, Uri.parse (uri)) .setPackage (getTargetContext () .getPackageName ()); return intent;}Step 3Launch the intent employ the Activity Rule
Intent intent = getDeepLinkIntent (deepLinkUri); mActivityRule.launchActivity (intent);
Here & # 8217; s a sample examination that captures the above measure of Deep Link Testing using ActivityTestRule and Espresso Intent
import android.support.test.espresso.intent.Intents import android.support.test.espresso.intent.Intents.intended import android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent import android.support.test.rule.ActivityTestRule import android.support.test.runner.AndroidJUnit4 import org.junit.After import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import android.content.Intent meaning android.net.Uri @ RunWith (AndroidJUnit4: :class) class DeepLinkingTest {@ Rule @ JvmField val activityTestRule = ActivityTestRule (MainActivity: :class.java) @ Before fun setUp () {Intents.init ()} @ After fun tearDown () {Intents.release ()} @ Test fun should_launch_secondActivity_when_deepLinkingToActivityTwo () {val intent = Intent (Intent.ACTION_VIEW, Uri.parse (`` myapp: //example.com? screen=activitytwo '')) activityTestRule.launchActivity (aim) intended (hasComponent (SecondActivity: :class.java!! .getName ()))}}How to essay Deep Links on iOS?
Following is the method to test deeplink iOS devices:
Using XCUITest
Use XCUIApplication class to establish, monitor, and terminate your app in a UI Test.
- For Launching the Application, enter the below dictation.
app.launch ()
- For Terminating the Application, use the next command.
app.terminate ()
- For Activating the Application, enter the next bid.
app.activate ()
To perform a UI test of a Safari deeplink, it is recommended that the required app should run in the background. If any other app is launched during an ongoing UI test, it is similar to launching the required app, but with a different bundle identifier. For launching Safari, the bundle identifier & # 8220; com.apple.mobilesafari & # 8221; is triggered.
To launch the compulsory app and switch rearward to Safari right after, run the following codification:
func testDeeplinkFromSafari () {let app = XCUIApplication () app.launch () let safari = XCUIApplication (bundleIdentifier: `` com.apple.mobilesafari '') safari.launch ()}For deeplinking rearwards to the app, Safari has to be controlled similar to any regular. This can be perform in three steps:
- name the address bar,
- type the deep link URL,
- click on the & # 8220; Go & # 8221; button.
Ideally, Safari will deeplink back to the required app, limn that the deeplink logic in the app is working as expected.
func testDeeplinkFromSafari () {// Launch our app let app = XCUIApplication () app.launch () // Launch Safari and deeplink backward to our app openFromSafari (`` swiftrocks: //profile '') // Make sure Safari properly switched backward to our app before asserting XCTAssert (app.wait (for: .runningForeground, timeout: 5)) // Assert that the deeplink worked by checking if we 're in the `` Profile '' screen XCTAssertTrue (app.navigationBars [`` Profile ''] .exists)} private func openFromSafari (_ urlString: String) {let safari = XCUIApplication (bundleIdentifier: `` com.apple.mobilesafari '') safari.launch () // Make certain Safari is genuinely bunk before asserting XCTAssert (safari.wait (for: .runningForeground, timeout: 5)) // Type the deeplink and action it let firstLaunchContinueButton = safari.buttons [`` Continue ''] if firstLaunchContinueButton.exists {firstLaunchContinueButton.tap ()} safari.buttons [`` URL ''] .tap () let keyboardTutorialButton = safari.buttons [`` Continue ''] if keyboardTutorialButton.exists {keyboardTutorialButton.tap ()} safari.typeText (urlString) safari.buttons [`` Go ''] .tap () _ = confirmationButton.waitForExistence (timeout: 2) if confirmationButton.exists {confirmationButton.tap ()}}It is best to add the extra wait (for: .runningForeground) asseveration for refuge. Inserting additional hold grant insure whether the app switching worked before the attempt to assert. If it neglect, then it is evident that the failure is because the app failed to trade, and not due to something not be present in the UI of the app.
Read More:
Testing Deep Links on Real Device Cloud
When testing deeply linking on Real Devices, deeplink tester can decode the issues that could cause interruption or adapted behavior of the deep link. Testing on BrowserStack ’ s includes all the real user conditions while performing tests. Thus, allowing developer to screen on 3500+ browser-device combination for.
- offers cloud-based access to the latest and legacy devices (Android, iOS, and Windows) installed with real operating systems.
- App Automate besides requires no extra setup, helping testers save precious clip and meet their deadlines much faster.
Since users demand high-functioning and engaging crusade, deep linkup examination is a requirement before unloose any campaign. By running deep link tests on, deeplink examiner can ensure that apps work as expected in. Run as many test as possible on real Android devices to offer a consistently optimum user experience.
Conclusion
Since users demand high-functioning and engaging campaigns, deep link testing is a requirement before releasing any run. By running deep link tests on, deeplink testers can secure that apps work as expected in. Run as many tests as potential on real Android devices to proffer a systematically optimal user experience.
# Ask-and-Contributeabout this issue with our Discord community.
Related Guides
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free