testsigma
Topics
left-mobile-bg

How to do Deep Link Testing on Android & iOS devices?

January 22, 2024Raunak Jain
right-mobile-bg
How to do Deep Link Testing on Android & iOS devices
image

Start automating your tests 10X Faster in Simple English with Testsigma

Try for free

A deep link is not merely a URL; rather, it serves as a navigational tool, directing users to precise locations within an application, bypassing the conventional homepage. Unlike regular links, deep links transcend the surface, enabling developers to craft a more personalized user experience by directing individuals to specific pages, products, or features.

To break it down further, imagine your app is a book, and the deep link is like a bookmark that takes you straight to a specific chapter. Deep link testing is like checking if that bookmark reliably opens the correct page every time you click on it. 

Whether you’re using an Android or iOS device, the goal is to make sure users seamlessly reach their desired destinations within the app. In this guide, we’ll delve into the practical steps of deep link testing to guarantee the efficiency and accuracy of these navigational shortcuts.

Table Of Contents

Consider another scenario where you’re casually browsing the internet on your mobile browser. You come across a link to a product in an online shopping app. Now, if the shopping app is already installed on your phone, clicking on the link doesn’t just take you to the app’s homepage—it directs you straight to the specific product page. This seamless transition from the browser to the app is facilitated by deep linking.

How it Works?

When you click on a deep link from the browser, the link carries information that tells your phone which app to open and where to go within that app. It’s like a custom address that guides your device to the exact spot you’re interested in. This process is especially handy when you have multiple apps that can handle similar links.

For instance, if you have different map apps installed, clicking on a location link in your browser triggers your phone to open the map app you prefer, rather than just a default one. This smart redirection is made possible by deep linking, streamlining your experience and saving you from the hassle of navigating through apps manually.

Deep link testing, in this case, ensures that when you click on a link, it accurately identifies the installed app on your mobile and smoothly directs you to the relevant content. It involves verifying that the deep link seamlessly integrates the browser and the app, offering users a convenient and efficient transition between the two platforms. 

In essence, deep link testing ensures that the connection between the browser and the app is not just functional but also enhances the user experience by effortlessly bridging the gap between web content and app functionality.

Here are a few reasons to understand why deep links are so important in complex application user flows.

  • Enhanced User Experience: Deep links enable users to bypass the app’s homepage and navigate directly to the desired content, saving time and improving overall satisfaction.
  • Targeted Marketing Campaigns: Deep links facilitate precise user redirection, allowing marketers to create personalized campaigns that lead users to specific promotions, products, or features.
  • Seamless App-to-Web Integration: They bridge the gap between mobile apps and web content, offering a smooth transition for users clicking on links from browsers to open specific app pages.
  • Improved App Discoverability: Utilizing deep links in marketing efforts, such as email campaigns or social media, increases the likelihood of users discovering and engaging with specific in-app content.
  • Cross-Platform Consistency: They work seamlessly across various platforms (Android, iOS), ensuring a consistent user experience regardless of the device used.
  • Efficient User Onboarding: They can guide new users directly to onboarding tutorials, helping them quickly understand and navigate key features within an app.
  • App Indexing for Search Engines: Deep links contribute to app indexing, allowing search engines to crawl and index app content, potentially improving app visibility in search results.

Deep links consist of essential components that define their behavior and destination within a mobile application. Understanding these building blocks is crucial for developers and marketers aiming to harness the full potential of deep linking.

  1. Scheme: The scheme is the protocol used to identify the type of link. Common schemes include “https” for web links and “myapp” for deep links. For instance, a deep link might start with “myapp://”.
  1. Host: The host specifies the domain or entity responsible for handling the deep link. In a web link, the host could be a website domain. In a deep link, it might be the app’s package name or a specific endpoint.
  1. Path: The path delineates the specific location or content within the app that the deep link should open. For example, “/products” could direct users to a product page within an e-commerce app.
  1. Query Parameters: These parameters provide additional information to the app, influencing its behavior. For instance, a deep link could include parameters like “?productID=123” to directly open a particular product.
  1. Fragment: Fragments are optional components that indicate a specific section within the targeted content. In a deep link, “#section2” might navigate to a particular section of an article in a news app.

Consider a hypothetical deep link for a travel app:

travelapp://destination/details?place=paris&category=sightseeing#maps

  • Scheme: “travelapp”
  • Host: “destination”
  • Path: “/details”
  • Query Parameters: “place=paris” and “category=sightseeing”
  • Fragment: “#maps”


This structured approach allows developers to craft precise links, ensuring users are directed to the intended content or functionality within the app.

Deep links come in different flavors, each serving specific purposes and catering to diverse user interactions. Understanding these types is essential for developers aiming to implement targeted and effective deep-linking strategies.

Example: myapp://product/details

Description: These links directly point to a specific content or feature within the app. However, they might not handle scenarios where the app isn’t installed.

Example: myapp://special-offer?utm_source=email

Description: These links carry additional information, such as source attribution. Even if the app isn’t installed, users are directed to the specific content after installing.

Example: myapp://category/electronics?productID=123

Description: Contextual deep links not only navigate to a particular section but also provide context through parameters. In this case, it specifies both the category and a specific product.

Example: https://example.com/product/details

Description: These links seamlessly transition between web and app content. They direct users to the app if it’s installed or the website if it’s not, ensuring a consistent experience.

Custom URL Schemes:

Example: customscheme://open/settings

Description: Apps can register custom URL schemes, allowing them to respond to specific links. These are commonly used for deep linking within an app.

Smart App Banners:

Example: Displayed when visiting a website, prompting users to open the corresponding app.

Description: A visual cue on the website encourages users to transition from the mobile browser to the app, promoting a cohesive experience.

Understanding the nuances of these deep link types empowers developers to implement strategies that align with their app’s goals, marketing initiatives, and user experience objectives.

Check this out to know about the different types of software testing.

Deep Linking Test Cases

Ensuring the robust functionality of deep links is crucial for providing a seamless user experience. Let’s explore three distinct test scenarios with their corresponding test cases:

Description:

This test case ensures that when a user clicks on a deep link associated with the social media app from a browser, the application installation is prompted, and the user is seamlessly directed to the relevant content upon installation.

Precondition:

The social media app is not installed on the device.

Test Steps:

  1. Open a web browser on the device.
  2. Click on a deep link associated with the social media app, e.g., https://socialmediaapp.com/user/profile.
  3. Verify that a prompt suggests installing the social media app.
  4. Proceed with the app installation process.
  5. After installation, open the app and ensure the user is directed to the specified profile page (/user/profile).

Acceptance Criteria:

  1. Clicking on the deep link in the browser prompts the user to install the social media app.
  2. The app installation process is smooth and successful.
  3. Upon opening the installed app, the user is directed to the specified content mentioned in the deep link.

Description:

This test case ensures that when multiple apps capable of handling the same deep link are installed, the correct social media app is opened based on the user’s preference or default settings.

Precondition:

Multiple social media apps capable of handling the deep link are installed on the device.

Test Steps:

  1. Click on a deep link associated with the social media app from an external source, e.g., a message or email.
  2. If prompted, choose the social media app through which to open the link.
  3. Verify that the selected social media app opens, and the user is directed to the specified content mentioned in the deep link.

Acceptance Criteria:

  1. Clicking on the deep link from an external source allows the user to choose among installed social media apps.
  2. The selected app opens, and the user is directed to the specified content in the deep link.
  3. The process works seamlessly even when multiple social media apps capable of handling the link are installed.

Description:

This test case focuses on validating the behavior of deep links within the social media app. It ensures that clicking on an in-app deep link leads to the intended content within the application.

Precondition:

The social media app is installed on the device, and the user is logged in.

Test Steps:

  1. Open the social media application on the device.
  2. Navigate to a section within the app where a deep link is available, for example, a user’s profile page.
  3. Click on an in-app deep link, e.g., socialmediaapp://user/profile.
  4. Verify that the app responds to the deep link and navigates to the specified content, in this case, the user’s profile page.

Acceptance Criteria:

  1. The social media app is installed, and the user is logged in.
  2. Clicking on the in-app deep link within the social media app triggers the expected navigation.
  3. The user is seamlessly directed to the specified content within the app, confirming the successful execution of the deep link.

In Android, deep linking involves establishing associations between activities and intent filters in the AndroidManifest.xml file. Intent filters specify the conditions under which a particular activity should be launched, and for deep linking, these filters are crucial for responding to specific types of links.

Intent Filter Definition:

  • The <intent-filter> element encapsulates the conditions for launching the associated activity.
  • <action> tag specifies the action, such as “android.intent.action.VIEW.”
  • <category> tags define categories, with “DEFAULT” indicating a general view action and “BROWSABLE” indicating compatibility with web browsers.

In the AndroidManifest.xml file:

Deep links are configured through the <data> tags within the intent filter, outlining the structure of URIs that the activity can handle. This configuration ensures that the activity responds appropriately to specific types of links.

Example 1: Classic URL Structure:

  1. Scheme: “https”
  2. Host: “deeplink.example”
  3. Path: No specific path requirement (any path under the host is acceptable)
  4. This allows the associated activity to open links like https://deeplink.example and https://deeplink.example/hello_world.

Example 2: Custom URI Structure:

  1. Scheme: “testsigma”
  2. Host: “test”
  3. Path: “/hello”
  4. This configuration enables the associated activity to open links like testsigma://test/hello or testsigma://test/hello?test=1.

Exporting Activities for Deep Linking:

For an activity to handle deep links, it must be marked as exported in the AndroidManifest.xml file. This is achieved by adding android:exported=”true” to the activity declaration.

Practical Implications and Penetration Testing:

Deep linking facilitates a seamless user experience by directing users to specific content within an app. In a security context, during a mobile application penetration test, detecting deep links involves examining the APK and inspecting the AndroidManifest.xml file.

Detection Process:

  • Decompiling the APK is necessary to access the AndroidManifest.xml file.
  • Presence of deep links can be identified by inspecting intent filters within the manifest.
  • Security assessments may involve scrutinizing how deep links are configured to ensure secure handling of user data and proper validation of incoming links.

As discussed, in Android, the association between intents and deep links is fundamental for seamless navigation within applications. To reiterate, intents serve as the mechanism by which activities can perform actions following the reception of data. Deep links, implemented through intent filters in the AndroidManifest.xml file, allow specific activities to respond to particular types of links, enhancing user experience.

Here, we explore three methods for testing deep links on Android: using Android Debug Bridge (ADB), employing ActivityTestRule and Espresso Intent for unit testing, and leveraging the Appium Driver for automated mobile app testing.

Using Android Debug Bridge (ADB):

Testing deep links with ADB involves simulating the behavior of a user clicking a link on a device. ADB can be utilized to open deep links manually and verify the expected behavior.

adb shell am start -a android.intent.action.VIEW -d “https://deeplink.example”

This command sends an intent to open the specified deep link. Ensure that the device is connected and the app is installed. This method is useful for manual testing and quick verification of deep link functionality.

Using ActivityTestRule and Espresso Intent:

For unit testing, ActivityTestRule and Espresso Intent can be employed to simulate deep link handling within automated test cases.

@RunWith(AndroidJUnit4.class) public class DeepLinkTest { @Rule public ActivityTestRule activityRule = new ActivityTestRule(DeepLinkExample1.class, true, false); @Test public void testDeepLinkExample1() { Uri uri = Uri.parse(“https://deeplink.example”); Intent intent = new Intent(Intent.ACTION_VIEW, uri); activityRule.launchActivity(intent); // Add Espresso assertions to verify the expected behavior onView(withId(R.id.exampleTextView)).check(matches(withText(“Hello, Deep Link!”))); } }

This Espresso test case uses ActivityTestRule to launch the activity associated with the deep link and Espresso Intent to handle the deep link intent. Assertions can be added to ensure the correct behavior of the app in response to the deep link.

Using Appium Driver:

For end-to-end testing, Appium can be used with the Appium Driver to automate interactions with the app and validate deep link functionality.

@Test public void testAppiumDeepLink() { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability(“platformName”, “Android”); capabilities.setCapability(“deviceName”, “emulator-5554”); capabilities.setCapability(“appPackage”, “com.example.myapp”); capabilities.setCapability(“appActivity”, “.DeepLinkExample1”); AndroidDriver driver = new AndroidDriver(new URL(“http://localhost:4723/wd/hub”), capabilities); // Use Appium commands to navigate to the deep link driver.executeScript(“mobile: deepLink”, ImmutableMap.of(“url”, “https://deeplink.example”)); // Add assertions to validate the expected behavior Assert.assertEquals(driver.findElementById(“com.example.myapp:id/exampleTextView”).getText(), “Hello, Deep Link!”); driver.quit(); }

In this Appium example, the Appium Driver is used to automate the interaction with the app, and deep linking is tested by executing a script to navigate to the specified deep link. Assertions can be added to verify the correctness of the app’s response.

These testing approaches cover a range of scenarios, from manual verification using ADB to automated unit testing and end-to-end testing with frameworks like Espresso and Appium.

Testing deep links on iOS involves simulating user interactions with links and ensuring that the app responds appropriately. Below is a detailed explanation along with code examples for testing deep links on iOS.

Manual Testing using Safari:

For manual testing, you can open deep links in Safari on the iOS device or simulator to check if the app is launched correctly. This is a straightforward method to quickly verify the deep link behavior.

XCTest Framework for Unit Testing:

Using XCTest, you can write unit tests to validate the handling of deep links in your iOS app. Here’s an example XCTest class:

import XCTest class DeepLinkTests: XCTestCase { func testDeepLinkExample() { let app = XCUIApplication() app.launchArguments.append(“-deepLinkURL”) app.launchArguments.append(“myapp://example”) app.launch() // Add XCTest assertions to verify the expected behavior XCTAssertTrue(app.staticTexts[“Hello, Deep Link!”].exists) } }


In this example, we are adding a launch argument -deepLinkURL with the value of the deep link to the app. The test then launches the app, and XCTest assertions are used to validate the expected behavior of the app in response to the deep link.

UI Testing with XCUITest:

XCUITest allows you to write UI tests to simulate user interactions. Here’s an example of testing deep links using XCUITest:

import XCTest class DeepLinkUITests: XCTestCase { func testOpenDeepLink() { let app = XCUIApplication() app.launchArguments.append(“-deepLinkURL”) app.launchArguments.append(“myapp://example”) app.launch() // Use XCUITest interactions to validate the expected UI elements XCTAssertTrue(app.staticTexts[“Hello, Deep Link!”].waitForExistence(timeout: 5)) } }

Similar to the XCTest example, we add a launch argument with the deep link URL, launch the app, and use XCUITest interactions to validate the UI elements.

Using URL Schemes in AppDelegate:

In your app’s AppDelegate.swift, you can handle deep links in the application(_:open:options:) method. Here’s a simplified example:

import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { if url.scheme == “myapp” { // Handle the deep link URL, e.g., navigate to a specific view controller return true } return false } // … other AppDelegate methods }

In this code snippet, the open url method is called when the app is opened with a URL. You can check the scheme and handle the deep link accordingly.

Using SafariViewController for Testing:

You can also use SafariViewController to open deep links within your app for testing purposes:

import UIKit import SafariServices class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Example: Open a deep link using SafariViewController if let url = URL(string: “myapp://example”) { let safariViewController = SFSafariViewController(url: url) present(safariViewController, animated: true, completion: nil) } } }

This allows you to simulate the behavior of opening a deep link within your app using SafariViewController for testing.

Testing deep links on real devices is crucial for ensuring that your app functions correctly across a variety of devices and environments. Real Device Cloud (RDC) services offer a solution by providing access to a diverse set of physical devices for testing. Testsigma is an example of an AI-powered test automation platform that supports real device testing, and here’s an example on how to test deep links using Testsigma:

Setting Up a Project:

  • Begin by signing up for a free Testsigma account and creating a new project dedicated to your application.
  • In the project settings, configure details such as the application under test, test environment specifications, and any other relevant configurations.
  • Within Testsigma, design test cases specifically focused on deep link testing.
  • Define the sequence of steps that simulate user interactions with your app, including launching the app and interacting with deep links.
Creating Test Cases for Deep Links:

Test Scripting and Actions:

  • Testsigma operates on a scriptless testing approach, enabling users to design test cases without the need for coding. Test cases are constructed using natural language statements and predefined actions.
  • In the case of deep link testing, you can utilize predefined actions to simulate the process of opening deep links, navigating through the app, and verifying the expected outcomes.
Test Scripting and Actions:

Selecting Target Devices and Configurations:

  • Testsigma’s real device cloud boasts over 3000 real devices, browsers, and OS combinations. In the test case configuration, specify the target devices and configurations on which you want to execute the deep link tests.
  • You can choose from a diverse range of devices, including various models of smartphones and tablets, running different versions of operating systems.

Configuring Network Conditions:

  • To simulate real-world scenarios, Testsigma allows you to configure network conditions such as different network speeds and latency.
  • This feature helps assess how the app behaves when users access deep links under varying network conditions.
Configuring Network Conditions:

Executing Test Cases:

  • Initiate the test execution process within Testsigma, specifying the devices and configurations you’ve chosen.
  • Testsigma’s cloud infrastructure handles the distribution of test cases across selected devices, running them concurrently for efficiency.
Executing Test Cases:

Real-Time Monitoring and Logs:

  • During test execution, Testsigma provides real-time monitoring of the progress. You can view logs, screenshots, and other diagnostic information to identify any issues related to deep link handling.
  • Identify any failures, view detailed logs, and use built-in collaboration features to communicate issues with team members.


Let’s have a look at some of the challenges that are often faced when we test deep links. Addressing these challenges requires a comprehensive testing strategy that includes a combination of manual testing, automation, and real-device testing to validate deep link functionality across a broad range of scenarios and conditions.

  • Platform Fragmentation: Testing deep links across various mobile operating systems (iOS, Android) and their multiple versions introduces challenges. Each OS may interpret and handle deep links differently, requiring thorough testing on different platforms.
  • App Installation State: It involves scenarios where the app might not be installed on the device. Ensuring correct behavior, such as redirecting to the app store for download and then opening the deep link, adds complexity to the testing process.
  • Varying Network Conditions: Deep link testing should consider different network conditions, including low connectivity, high latency, or network dropouts. Simulating these conditions accurately during testing is challenging but crucial to assess the app’s robustness.
  • Permission Handling: Deep links might lead to functionalities that require specific app permissions. Testing how the app handles permissions, especially when the user denies access, is essential for a secure user experience.
  • Automation Tool Compatibility: Automating deep link testing can be challenging due to variations in automation tool compatibility with different platforms and frameworks. Ensuring seamless integration with test automation tools for both Android and iOS platforms requires careful consideration.
  • Attribution and Analytics: Deep links are often used for tracking user interactions and marketing campaigns. Testing the accuracy of attribution and analytics data generated from deep link interactions poses challenges, especially in complex scenarios involving multiple deep links.
  • Handling App State: Testing deep links involves scenarios where the app might be in a specific state when the link is opened. Managing and validating app states accurately during testing, including scenarios where the app is in the background or terminated, is a challenge.
  • Browser and Platform Variations: In cases where deep links are accessible through web pages, ensuring consistent behavior across different browsers and platforms adds complexity to the testing process. Variations in URI handling and link interpretation need to be thoroughly tested.
  • User Journey Flow: Verifying a seamless user experience during deep link navigation, especially when transitioning between different parts of the app or from a web page to the app, requires meticulous testing. Ensuring that users are directed to the expected content without disruptions is critical.

Conclusion

In conclusion, testing deep links is an integral part of ensuring a seamless and reliable user experience in mobile applications. The diverse challenges associated with deep link testing, ranging from platform fragmentation to handling various app states and network conditions, underscore the complexity of validating these crucial user pathways. 

As mobile apps continue to evolve and serve diverse user needs, the robust validation of deep link functionality not only contributes to enhanced user satisfaction but also ensures the app’s resilience in the face of dynamic operating environments. By leveraging sophisticated testing tools and platforms like Testsigma, which provide access to real devices, browsers, and OS combinations on the cloud, development teams can navigate the intricacies of deep link testing, fortifying their applications against the uncertainties of the mobile landscape.



Check out this article to know more about mobile testing.

Frequently Asked Questions

The deep link method is a mechanism that allows users to navigate directly to a specific page or content within a mobile application rather than just launching the app’s homepage. Deep links use unique Uniform Resource Identifiers (URIs) to pinpoint and open a particular section of an app. There are different types of deep links, such as traditional deep links, universal links on iOS, and app links on Android, each serving specific purposes. These links are defined using intent filters in the AndroidManifest.xml file for Android apps, specifying the conditions under which a particular activity in the app should respond to a deep link.

A deep link example could be a URL that directs users to a specific product page within an e-commerce app. For instance, a deep link might look like myecommerceapp://product/12345, where “myecommerceapp” is the app’s custom scheme, and “product/12345” specifies the unique identifier for the product. Clicking on this link would open the app directly to the details of the product with ID 12345, providing a seamless and targeted user experience. Deep links can be customized to navigate to various sections, features, or content within an app.

To protect against attacks exploiting deep links, developers and app owners should implement secure practices. This includes validating and sanitizing input parameters from deep links to prevent injection attacks. Additionally, implementing proper authorization and authentication mechanisms ensures that sensitive actions triggered by deep links are performed securely and only by authorized users. Regular security audits and penetration testing should be conducted to identify and address potential vulnerabilities. Utilizing secure communication protocols, such as HTTPS, for deep links is also crucial to protect against interception and tampering during data transmission.

Topics

image

Start automating your tests 10X Faster in Simple English with Testsigma

Try for free
imageimage
Subscribe to get all our latest blogs, updates delivered directly to your inbox.

RELATED BLOGS


Types of Testers: A Comprehensive Guide 
RAHUL PARWAL
AUTOMATION TESTING
Automated Test Oracles in Software Testing
KIRUTHIKA DEVARAJ
AUTOMATION TESTING
Accelq vs Provar | Which One You Should Choose?
TESTSIGMA ENGINEERING TEAM
AUTOMATION TESTING