Native App vs Hybrid App
Before proceeding further, let's take a look at what are the different types of apps. In mobile app automation, you will come across two main types of apps: Native Apps and Hybrid Apps. Understanding the difference between these app types is essential because Appium interacts with each of them in slightly different ways.
What is a Native App?
A Native App is an application built specifically for a particular mobile operating system, such as Android or iOS. It is developed using languages and tools specifically designed for that OS:
- Android: Native apps are built using Java or Kotlin.
- iOS: Native apps are built using Swift or Objective-C.
Examples of Native Apps:
- The Phone app on Android or iOS
- The Messages app on Android or iOS
- Any app that you download from the Google Play Store or Apple App Store that is built for one platform only
How Appium Handles Native Apps:
- Appium can interact directly with the elements of native apps using various locator strategies (like ID, Accessibility ID, XPath, etc.).
- Appium’s Native Context allows it to work directly within the native layer of the app, enabling it to interact with native UI elements.
What is a Hybrid App?
A Hybrid App is a mobile app that combines elements of both native and web applications. It is typically developed using web technologies (like HTML, CSS, and JavaScript) but is wrapped in a native container. This means it can be installed from app stores like a native app, but it loads some or all of its content using a web browser within the app.
In simple terms, a hybrid app is a web app inside a native shell.
Examples of Hybrid Apps:
- Some social media or e-commerce apps that use web-based content for certain sections, like profile pages or shopping screens.
- Applications built using frameworks like Ionic, React Native, or Apache Cordova, which allow developers to create a single codebase for both Android and iOS.
How Appium Handles Hybrid Apps:
- Appium can switch between Native Context and WebView Context in hybrid apps.
- WebView is the embedded browser used in hybrid apps to display web content. When Appium switches to WebView context, it treats the app like a browser and interacts with it using web-based locators (like CSS selectors).
Key Differences Between Native and Hybrid Apps in Appium
Native App
- Development : Built with platform-specific languages
- Access to Features : Full access to device features
- Performance : Faster and smoother
- Automation Context : Native Context only
- Locators Used : Native locators like ID, XPath
Hybrid App
- Development : Built with web technologies + native wrapper
- Access to Features : Limited, needs plugins for some device features
- Performance : May be slightly slower due to WebView usage
- Automation Context : Requires switching between Native and WebView Contexts
- Locators Used : Web locators in WebView, native locators in Native Context
We will learn more about context switching and how to interact with elements of both hybrid and native apps in later part of the tutorial. For now it is important to understand the differences between the two.