Skip to main content
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Test the shake gesture with Maestro

Simulate a device shake on real iOS devices during a Maestro test on BrowserStack App Automate, and check your app’s response to the shake in your flow.

This feature is available only under Device Cloud Pro, Device Cloud Pro + Visual Cloud, and Enterprise Pro plans. For more details, check out our pricing page.

Some apps respond when you shake the device. For example, a shake can open a debug menu, undo an action, switch between environments, or open a feedback form.

On BrowserStack App Automate, you can trigger a shake on a remote iOS device during a Maestro test. Your flow sends the shake at the point where your app expects it, and your app responds as though someone shook the device.

Supported devices and OS versions

The shake gesture works on real iOS devices only, including private devices. The following table lists the supported devices and OS versions:

Supported devices Supported iOS versions
iPhones and iPads 16 and later

Prerequisites

Before you start, make sure you have the following:

  • Your BrowserStack username and access key, available in the Account & Profile section of your dashboard.
  • An iOS app as an .ipa file.
  • A Maestro test suite zipped inside a single parent folder, as described in Prepare your Maestro test suite.

Run a Maestro test with the shake gesture

Complete the following steps to trigger a shake during a Maestro test:

Add the BrowserStack executor script to your test suite

Maestro doesn’t use the WebDriver protocol, so Maestro flows have no JavaScript executor of the kind that Appium tests use. BrowserStack provides a script that your flow calls with the runScript command instead. If you already added this script for another feature, such as biometric authentication, reuse the same file.

At the root of your test suite’s parent folder, create a folder named bstack and save the following script as browserstack_executor.js:

browserstack_executor.js
Copy icon Copy

Your test suite now has the following structure:

sample_parent_folder/
├── bstack/
│   └── browserstack_executor.js
├── flow1.yaml
└── flow2.yaml

Keep the bstack folder inside the parent folder that you zip, alongside your flow files. If the bstack folder sits outside the parent folder, the runScript step can’t resolve the path to the script. For the required layout, see Prepare your Maestro test suite.

Trigger the shake from your flow

Add a runScript step at the point in your flow where your app expects a shake. The following flow shakes the device to open a debug menu:

flow1.yaml
Copy icon Copy

Set BROWSERSTACK_EXECUTOR_ACTION to shake. The shake action takes no other env keys.

A status=200 line means BrowserStack sent the shake. To confirm your app received it, assert on your app’s response, as the example does.

BrowserStack triggers the shake through AssistiveTouch and turns AssistiveTouch off right after each shake. If AssistiveTouch was already on in the session, for example for Apple Pay, it stays on until the session ends. Session cleanup turns it off, so nothing carries over to the next session on that device.

Upload your app and test suite

Upload your app and your zipped Maestro test suite, then note the app_url and test_suite_url that each response returns. You need both values to start a build. For the upload commands, see Execute Maestro tests.

Run your test

Start the build with your app and test suite as usual. You don’t need a build parameter. BrowserStack turns on the shake gesture for Maestro iOS sessions when your plan includes it and the device runs iOS 16 or later. For the build command, see Execute Maestro tests.

Check the result in your logs

Each call that reaches the executor writes a status line to your Maestro logs. A successful call shows a line such as the following:

[EXECUTOR] action=shake status=200 reason=ok

A failed call shows the HTTP status and a reason on the same line, and stops the flow. The following table lists the reasons for a failed shake:

Reason Status Cause
feature_not_available_in_current_plan_for_aa 403 Your plan doesn’t include the shake gesture.
incompatible_os_version 403 The device runs a version earlier than iOS 16.
scope_denied 403 The shake gesture isn’t turned on for the session.
unknown_action 404 The value of BROWSERSTACK_EXECUTOR_ACTION isn’t a recognized action. Check that it’s set to shake.
parallel_custom_gestures_command_error 409 Your flow sent a shake while another shake was still running on the device.
executor_internal_error 500, 502, or 504 The shake failed on the device or timed out.
shake_disabled 503 BrowserStack has turned off the shake gesture temporarily.
executor_unreachable unreachable The flow couldn’t connect to the executor.

If the session isn’t set up for the executor, the runScript step fails without writing an [EXECUTOR] line to your logs. To read these lines, see Maestro logs.

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