Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 37 ยท Getting Started

Native, Hybrid and Mobile Web Apps

Understand the three kinds of mobile apps Appium can test, how contexts switch between native and web views, and what each type means for your locators.

Before you automate an app you need to know what kind of app it is. The answer decides which driver you use, which locators work and whether you must switch between contexts. Appium treats all three kinds of mobile apps uniformly at the protocol level, but they look very different from the inside.

This lesson defines native, hybrid and mobile web apps, shows how Appium sees each one and introduces contexts, the mechanism that lets one test move between a native screen and a web page inside the same app.

Native apps

A native app is written with the platform's own toolkit and installed from an APK, AAB or IPA file. On Android the screen is a tree of View objects (or Compose nodes); on iOS it is a tree of UIView objects or SwiftUI elements. Appium reads that tree through the platform's accessibility and automation layer and exposes every element with attributes such as text, class, bounds and an accessibility label.

  • Fast and reliable: elements are real UI objects.
  • Locators: accessibility id, resource id, class name, XPath, plus platform selectors (covered in Locator Strategies).
  • You usually supply the app file in the capabilities (appium:app), or the package/bundle id of an app that is already installed.

Mobile web apps

A mobile web app is just a website. You automate it inside a mobile browser: Chrome on Android, Safari on iOS. There is no app file to install; you set the browserName capability (Chrome or Safari) and then use the WebDriver commands you would use in Selenium, such as get(url) and CSS selectors.

Appium acts as a bridge: for Chrome it uses a chromedriver that matches the browser version, and for Safari it uses the iOS web inspector connection. Version matching is the usual source of problems here, so remember it when a mobile web test refuses to start.

Hybrid apps

A hybrid app is a native shell that hosts one or more web views. Banking apps, many shopping apps and apps built with Ionic or Cordova work this way. A single screen can contain a native toolbar on top and a web page below it. Tests for such apps must be able to talk to both worlds.

Appium solves this with contexts. A context is the world your commands are currently sent to:

  • NATIVE_APP is the native layer. This is the default context.
  • WEBVIEW_<something> is a web view. On Android the name is usually WEBVIEW_<package>; on iOS it is WEBVIEW_<number>.

The commands are getContexts (list them) and switchTo.context(name) (change). Once you are in a web view context, find_element accepts CSS selectors, and the DOM is what you see. Switch back to NATIVE_APP to press the system back button or handle a native permission dialog.

Python
# Read-only: real Python client usage
print(driver.contexts)          # e.g. ['NATIVE_APP', 'WEBVIEW_com.example.shop']
driver.switch_to.context("WEBVIEW_com.example.shop")
driver.find_element("css selector", ".checkout-button").click()
driver.switch_to.context("NATIVE_APP")

To inspect web views in a hybrid app, the app must have web contents debugging enabled on Android (WebView.setWebContentsDebuggingEnabled(true), usually in debug builds) and "Web Inspector" on for Safari on iOS. If contexts shows only NATIVE_APP, this setting is the first suspect.

Cross-platform frameworks

Apps built with React Native, Flutter, Kotlin Multiplatform or .NET MAUI are not "hybrid" in the web sense. React Native and MAUI render real native views, so Appium sees them like any native app. Flutter draws its own pixels, so a dedicated Flutter driver exists that understands Flutter's widget tree; without it, the screen looks like one big view. When your team picks a framework, check how testable its screens are through accessibility labels: well-labelled apps are easy to automate, unlabelled ones are painful.

Choosing the approach

Question If yes
Is there an APK/IPA to install? Native or hybrid: set appium:app
Does it open in a browser with a URL? Mobile web: set browserName
Does a screen show web content inside the app? Hybrid: use contexts
Does the app paint its own UI (Flutter, games)? Use the framework driver or image-based tools

The first stand-in classifies an app from a short description, the way you might decide on a driver strategy.

JS Stand-in: pick an automation strategy

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Switching contexts in a stand-in

The second stand-in imitates a hybrid app. It has a list of contexts and one command that routes find calls to either the native tree or the DOM. Real Appium does this for you; the code just makes the rule visible.

JS Stand-in: contexts route commands

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The most common hybrid-app bug is exactly the failure shown in the middle: the element exists on screen, but your command is going to the wrong context.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which capability tells Appium to automate a website instead of an installed app?

    A mobile web test starts a browser (Chrome or Safari), so you set browserName rather than an app file.
  2. 2. What is a context in a hybrid app test?

    NATIVE_APP and WEBVIEW_* are contexts; the active one decides how locators are interpreted.
  3. 3. You see only NATIVE_APP in the contexts list although the screen shows web content. What is a likely cause?

    Android WebViews must be debuggable, and Safari's Web Inspector must be on for iOS, before they appear as contexts.
  4. 4. How does Appium see a React Native screen?

    React Native renders real native views, so the normal native drivers and locators work.

Summary

  • Native apps expose a view tree; mobile web runs in Chrome or Safari; hybrid apps mix both.
  • Contexts (NATIVE_APP, WEBVIEW_*) decide where commands go; switch with the context commands.
  • Web views must be debuggable to appear in the context list.
  • React Native and MAUI look native to Appium; Flutter needs its own driver.
  • Good accessibility labels make any app easier to automate.

Next: Your First Appium Test