Skip to main content
🚀 See how 20+ AI Agents can make your QA faster and smarter. Join 10k+ QAs at global leadership summit! Register Now
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

Run Appium tests on foldable devices

Learn how to run your Appium tests on real foldable devices by automating fold and unfold state changes. Validate your app’s responsiveness and continuity on BrowserStack App Automate.

Test the responsiveness and continuity of your application on real foldable devices with App Automate. This guide explains how to control the device’s posture (folded/unfolded) during your automated test sessions.

To have this feature enabled for your account, contact BrowserStack Support.

Testing on foldable devices is currently supported on the following device:

  • Samsung Galaxy Fold 7

How to control device posture

You can change the device’s state between folded and unfolded by executing ADB shell commands through the browserstack_executor in your Appium test script. The session always starts with the device in its default folded state.

Key commands

You control the posture by executing an ADB shell command via the browserstack_executor:.

Get available states

The state identifiers (1, 2, etc.) can vary between device models. Before running tests, it’s a good practice to verify the correct identifiers for your target device.

Ruby
Copy icon Copy

Set device state (Fold/Unfold)

You can set the device state by passing the state ID. Typically, state 1 is for folded and state 2 is for unfolded.

Ruby
Copy icon Copy

Example test workflow

Here’s a typical test flow for a foldable device:

  1. Start session: Begin your App Automate session on a Samsung Galaxy Fold 7. The device will be in its default folded portrait state.
  2. Test cover screen: Run assertions to validate your app’s UI and functionality on the cover screen.
  3. Unfold the device: Send the unfold command (e.g., cmd device_state state 2).
  4. Wait for transition: Add a brief wait/delay to allow the app to resize and redraw its UI.
  5. Test main screen: Validate that the app’s layout correctly adapts to the larger screen. You can also test orientation changes (landscape/portrait) in this state.
  6. Fold the device: Send the fold command (e.g., cmd device_state state 1).
  7. Validate continuity: Verify that the app correctly transitions back to the cover screen state.
  8. End session: Terminate the session.

Best practices

Following are some best practices to ensure reliable test execution on foldable devices:

Use stable locators

As foldable devices dynamically change screen size and resolution, using static coordinates for element location is unreliable.

We recommend using stable locators like resource-id, accessibility-id, or XPath to ensure your tests can consistently find elements after a posture change.

Add waits after posture change

After triggering a fold or unfold command, add a brief wait (e.g., Thread.sleep(2000) or an Appium explicit wait) before your next command. This gives the application time to resize and redraw its UI, preventing element location failures.

Supported features

The following features are supported when testing on foldable devices:

  • Posture automation: Switching between folded and unfolded states.
  • Orientation changes: You can change the device orientation in both folded and unfolded states.

  • Comprehensive logs: Full video, text, and device log capture of all state transitions.
  • Element location: Standard Appium element location strategies work (see Best practices).

Limitations and scope

The following limitations apply when testing on foldable devices:

  • No half-fold state: Only fully folded and unfolded states are supported.
  • Interactive sessions: State changes in interactive sessions must also be triggered via ADB commands. Landscape mode is not supported in interactive sessions.
  • Split-screen apps: Testing apps in a split-screen view on the unfolded display is not supported.

View results

After your session is complete, you can verify the posture changes and their impact on your app using the following logs available on the App Automate dashboard. The following logs are available for your test session:

  • Video recording: The session video visually shows the device folding, unfolding, and rotating as triggered by your script.
  • Text logs & device logs: Logs contain entries that explicitly state when the device’s fold state has changed, helping you correlate test steps with device behavior.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle