Trigger Shake Gesture on iOS Devices
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
enableShakecapability - Trigger a shake manually in App Live and Browser Live
- Read the shake response and fix common failures
Supported Platforms
| Session | Android real devices | Android emulators | iOS real devices | iOS simulators |
|---|---|---|---|---|
| App Automation (Appium) | Your uploaded app, including its WebViews | Your uploaded app | iOS 16 and above | All iOS versions |
| Web Automation (Appium) | Chrome | Chrome | iOS 16 and above | Not supported |
| App Live (manual) | Shake Device button | Not supported | AssistiveTouch | Not supported |
| Browser Live (manual) | Shake Device button, Chrome only | Not supported | AssistiveTouch | Not supported |
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.
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.
- Python
- Java
- JavaScript (WebdriverIO)
response = driver.execute_script(
'lambda_executor: {"action": "gestures", "arguments": {"shake": true}}'
)
# response → "shake gesture triggered successfully"
String response = (String) ((JavascriptExecutor) driver).executeScript(
"lambda_executor: {\"action\": \"gestures\", \"arguments\": {\"shake\": true}}"
);
// response → "shake gesture triggered successfully"
const response = await driver.execute(
'lambda_executor: {"action": "gestures", "arguments": {"shake": true}}'
);
// response → "shake gesture triggered successfully"
Supported arguments
| Argument | Type | Description |
|---|---|---|
action | String | Must be "gestures" (lowercase). |
arguments.shake | Boolean | Set 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
- Open App Live, select your app, and open its App Settings.
- Turn on Shake Device Gesture.
- Start the session on an Android real device.
- In the session toolbar, open Device Controls and click Shake Device.
When the shake reaches your app, you see Shake gesture triggered successfully.
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
- Start a Browser Live session in Chrome on an Android real device and open your page.
- 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
| Scenario | Response |
|---|---|
| Shake delivered | shake gesture triggered successfully |
shake: false | shake gesture skipped (shake=false) |
Wrong type for shake | argument 'shake' must be a boolean, got string |
shake argument missing | missing required argument: shake |
| Wrong action casing | Please send a valid action for LambdaHook |
Android responses
| Message | What it means | What 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 app | The 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 LambdaTest | A pre-installed or Play Store app is on screen. | Shake works only for apps you uploaded to TestMu AI. |
shake gesture failed: browser not supported | A browser other than Chrome is on screen. | Use Chrome. |
shake gesture failed: no app in the foreground | The 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 screen | Chrome is open, but no tab is visible. | Open a tab with your page. |
shake gesture requires Android 9 or higher | The real device runs Android 8 or lower (app automation). | Use a device running Android 9 or higher. |
Session fails to start and lists enableShake | enableShake 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 organization | Android 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
devicemotionlisteners 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
devicemotionin 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.