Hero Background

Next-Gen App & Browser Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

Why is Appium not able to handle multiple screens or views in the application?

Appium struggles with multiple screens or views because it, and the underlying UiAutomator, focus on a single active window and the default display at a time. The view hierarchy dump and screenshot come from the primary display, so secondary displays and simultaneous split views fall outside its default focus. To reach another screen you must switch context, target a specific display id, or set the active application.

Understanding Screens, Views, and Contexts in Appium

The confusion around "multiple screens" usually comes from mixing three different concepts. Separating them makes the limitation, and the fix, much clearer:

  • Screen (display): A physical or logical display, such as a phone screen plus an external monitor. Appium captures the default display unless told otherwise.
  • View: A UI region within one app, like a native activity or an embedded webview. Multiple views can exist inside a single screen.
  • Context: The automation mode, either NATIVE_APP or a WEBVIEW handle. Appium interacts with one context at a time.

Why the Limitation Exists

  • Default display focus: UiAutomator dumps the active window hierarchy and screenshots the default display, so a secondary display is invisible unless targeted explicitly.
  • Single active window: Appium interacts with the focused window; the enableMultiWindows setting handles multiple windows on one display, not multiple physical displays.
  • One app active in split view: On iPadOS multitasking, only one app's elements are addressable at a time.
  • Historical driver scope: Multi-display support was not part of the original UiAutomator2 driver, though newer versions are adding it.

Switching Between Views Using Context

For hybrid apps, most "second view" problems are really context problems. List the available contexts, then switch to the webview to interact with web elements and back to native afterward:

// List all available contexts (NATIVE_APP, WEBVIEW_*)
Set<String> contexts = driver.getContextHandles();

for (String context : contexts) {
    if (context.contains("WEBVIEW")) {
        driver.context(context); // switch to the webview
        break;
    }
}

// interact with web elements here ...

driver.context("NATIVE_APP"); // switch back to native view

Targeting a Secondary Display on Android

When the app runs on a secondary physical display, launch it against a specific display id and capture that display's hierarchy and screenshot instead of the default one:

# Launch the app on display 1 (secondary display)
adb shell am start com.example.app --display 1
adb shell screencap -d 1 -p /sdcard/screencapture1.png
adb pull /sdcard/screencapture1.png .
adb shell uiautomator dump
adb pull /sdcard/window_dump.xml
mv window_dump.xml window_dump1.uix

For iPadOS split view, set the defaultActiveApplication setting to tell Appium which app to treat as active, then switch when you need the other pane. Learn the broader tooling in Appium testing.

Common Mistakes and Troubleshooting

  • Expecting elements from an unfocused screen: Appium only sees the active window. Move focus or target the display first.
  • Confusing enableMultiWindows with multi-display: That setting exposes multiple windows on one display, not separate physical screens.
  • Forgetting to switch back to NATIVE_APP: Staying in a webview context makes later native locators fail.
  • Using an outdated UiAutomator2 driver: Multi-display fixes ship in newer driver versions; upgrade before assuming it is impossible.
  • Relying on stale webview handles: Webview contexts change as the app navigates. Re-query getContextHandles() before switching.

Testing Multi-Screen Apps Across Real Devices

Multi-screen behavior often depends on the exact device, OS version, and display configuration, which is hard to reproduce on a single local emulator. With TestMu AI, you can run Appium tests on a real device cloud of 3000+ real browsers and devices, where each session isolates a real device and screen. This lets you validate context switching, webview flows, and multi-screen navigation across many device and OS combinations without maintaining a physical device lab, and complements broader mobile app testing.

Conclusion

Appium is not fundamentally unable to handle multiple screens or views; it defaults to a single active window and display. Once you separate screens, views, and contexts, the fixes become concrete: switch contexts for webviews, target a display id for secondary Android screens, and set the active app for iPad split view. For consistent results across devices, run these flows on a real device cloud.

Frequently Asked Questions

Why is Appium not able to handle multiple screens or views in the application?

Appium and the underlying UiAutomator dump only the active window's view hierarchy and capture the default display, so secondary displays and simultaneous split views are outside its default focus. You must switch context, target a specific display id, or set the active application to reach the other screen.

What is the difference between a screen, a view, and a context in Appium?

A screen is a physical or logical display, a view is a UI region such as a native activity or webview, and a context is either NATIVE_APP or a WEBVIEW handle. Appium switches views within an app using context switching, but physical displays need display-level commands.

How do I switch between native and webview screens in Appium?

Use getContextHandles() to list available contexts, then context() to switch to the webview or back to NATIVE_APP. Hybrid apps require switching to the webview context to interact with web elements and back to native for native elements.

Can Appium handle iPad split view or multitasking?

Appium can work with only one app's elements at a time in iPadOS split view. Using the defaultActiveApplication setting, you tell Appium which app to treat as active, then switch when you need to interact with the other pane.

Does Appium support Android secondary displays?

Historically Appium focused on the default display, but newer UiAutomator2 driver versions add support for interacting with objects across multiple displays. You can target a display by launching the app with a display id and capturing that display's hierarchy.

How can I reliably test multi-screen apps at scale?

Run your Appium tests on a real device cloud such as TestMu AI, where each session isolates a real device and screen. This removes local emulator display quirks and lets you validate multi-screen flows across many device and OS versions.

Related Questions

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests