For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

Trigger Shake Gesture on iOS Devices

Real Device Virtual Device

Trigger Shake Gesture on Android and iOS Devices

TestMu AI can simulate a physical shake on Android and iOS devices. Use it to test features that respond to a shake, such as bug-report and feedback screens, debug menus, environment switchers, shake-to-undo, shake-to-logout, and web pages that react to device motion.

Android and iOS use the same lambda_executor command, so one test script can shake both platforms.

By the end of this document, you will be able to:

  • Trigger a shake in Appium app automation and web automation on Android and iOS
  • Enable shake for your uploaded Android app with the enableShake capability
  • Trigger a shake manually in App Live and Browser Live
  • Read the shake response and fix common failures

Supported Platforms​

SessionAndroid real devicesAndroid emulatorsiOS real devicesiOS simulators
App Automation (Appium)Your uploaded app, including its WebViewsYour uploaded appiOS 16 and aboveAll iOS versions
Web Automation (Appium)ChromeChromeiOS 16 and aboveNot supported
App Live (manual)Shake Device buttonNot supportedAssistiveTouchNot supported
Browser Live (manual)Shake Device button, Chrome onlyNot supportedAssistiveTouchNot supported
note

Appium tests running on HyperExecute work the same way. No YAML change is needed.


Shake the Device in Appium Automation​

Step 1: Enable shake for your app (Android real devices only)​

For app automation on Android real devices, add enableShake: true to lt:options:

"lt:options": {
"platformName": "android",
"deviceName": "Galaxy S23",
"platformVersion": "13",
"app": "lt://APP_ID",
"isRealMobile": true,
"enableShake": true
}

Skip this step for iOS, for Android emulators, and for web automation in Chrome. No capability is needed there.

info

On Android, shake is delivered through TestMu AI's app instrumentation, so it requires app re-signing. A session that sets both enableShake: true and resignApp: false fails to start.

Step 2: Trigger the shake​

Call the lambda_executor hook with the gestures action. The command is the same on Android and iOS.

Verified
response = driver.execute_script(
'lambda_executor: {"action": "gestures", "arguments": {"shake": true}}'
)
# response → "shake gesture triggered successfully"

Supported arguments​

ArgumentTypeDescription
actionStringMust be "gestures" (lowercase).
arguments.shakeBooleanSet to true to trigger the shake. Set to false to skip without an error.

You can call the hook as many times as you need in a session. On Android, each call produces one shake that lasts about a second. Calls sent while a shake is running are queued, and each one still runs. Every shake call appears in the session's Command Logs.


Shake the Device in App Live and Browser Live​

Shake an Android app in App Live​

  1. Open App Live, select your app, and open its App Settings.
  2. Turn on Shake Device Gesture.
  3. Start the session on an Android real device.
  4. In the session toolbar, open Device Controls and click Shake Device.

When the shake reaches your app, you see Shake gesture triggered successfully.

note

Shake Device Gesture must be on when the app is installed in the session. If the app is already open, turn the setting on and reinstall the app.

Shake a web page in Browser Live on Android​

  1. Start a Browser Live session in Chrome on an Android real device and open your page.
  2. Open Device Controls and click Shake Device.

The page receives the shake as devicemotion events. No app setting is needed.

Shake an iOS device in App Live and Browser Live​

On iOS real devices, trigger a shake from the Shake Gesture option in AssistiveTouch. See AssistiveTouch on real iOS devices for App Live and AssistiveTouch on real iOS browsers for Browser Live.


Response Reference​

Common responses​

ScenarioResponse
Shake deliveredshake gesture triggered successfully
shake: falseshake gesture skipped (shake=false)
Wrong type for shakeargument 'shake' must be a boolean, got string
shake argument missingmissing required argument: shake
Wrong action casingPlease send a valid action for LambdaHook

Android responses​

MessageWhat it meansWhat to do
shake gesture triggered successfully (no listener received it) (automation), or Shake sent, but the app/page isn't listening for shakes (manual)The shake was delivered, but nothing on the screen was listening for it.Check that the screen that handles shakes is open.
shake gesture triggered successfully (page not served over https)Chrome on a real device doesn't send motion events to http:// pages.Serve the page over https://.
shake gesture failed: app not prepared for shake, enable shake and reinstall the appThe app on screen was installed without shake enabled.Set enableShake: true (automation) or turn on Shake Device Gesture (App Live), then reinstall the app.
shake gesture failed: app not installed by LambdaTestA pre-installed or Play Store app is on screen.Shake works only for apps you uploaded to TestMu AI.
shake gesture failed: browser not supportedA browser other than Chrome is on screen.Use Chrome.
shake gesture failed: no app in the foregroundThe home screen is showing, or the screen is off or locked.Bring your app or Chrome to the foreground.
shake gesture failed: no web page on screenChrome is open, but no tab is visible.Open a tab with your page.
shake gesture requires Android 9 or higherThe real device runs Android 8 or lower (app automation).Use a device running Android 9 or higher.
Session fails to start and lists enableShakeenableShake was combined with resignApp: false.Remove resignApp: false. Shake requires app re-signing.
Re-upload this app to enable Shake (App Settings)The app was uploaded before Android shake was enabled for your organization.Upload the app again.
Shake is not enabled for your organizationAndroid shake isn't enabled for your organization.Contact TestMu AI support.

Supported Shake Detection on Android​

A single shake is detected by the common ways Android apps and web pages listen for shakes, including:

  • Square Seismic (ShakeDetector)
  • React Native shake libraries
  • Custom accelerometer threshold and speed-change checks
  • Linear-acceleration listeners
  • devicemotion listeners in WebViews and in Chrome

A single shake can trigger a shake handler more than once, the same as shaking a physical phone.


Limitations​

iOS​

  • Real devices must run iOS 16 or higher.

Android​

  • Uploaded apps and Chrome only. On real devices, shake works in Chrome and in apps you uploaded to TestMu AI with shake enabled. Pre-installed apps and apps installed from the Play Store can't be shaken.
  • App re-signing is required. Apps that refuse to run after re-signing can't use shake.
  • Upload after enablement. Apps uploaded before Android shake was enabled for your organization must be uploaded again.
  • Native sensor code isn't supported. Apps that read the accelerometer from native (C/C++) code, such as some game engines, won't detect the shake.
  • Web pages: Chrome only. On real devices, the page must be served over HTTPS. Listen for devicemotion in the top-level page. Cross-origin iframes and the Generic Sensor API aren't supported.
  • Android 9 or higher is required on real devices for app automation.
  • Emulators support automation only. The Shake Device button isn't available on virtual devices.

Help and Support

Related Articles