Helpful Settings

Desired Capabilities

Desired Capabilities are used to configure webdriver when initiating the session.

Basic usage

const wd = require('macaca-wd');
const driver = wd.promiseChainRemote({
  host: 'localhost',
  port: 3456

const desiredCaps = {
  platformName: 'ios',
  deviceName: 'iPhone 6s',
  app: 'path/to/app'


Common Capabilities

Key Type Description
platformName String Which platform the app/browser should be running on. { iOS / Android / Desktop }
browserName String The name of the browser being used. { iOS: Safari } { Android: Chrome } { Desktop: Chrome / Electron }

App Capabilities

Key Type Description
deviceName String The name of the Simulator such as ‘iPhone 6’ or ‘Nexus 5x’.
app Stirng The absolute local path or remote http URL to an .ipa or .apk file, or a .zip containing one of these.
udid String Unique device identifier of the connected Device/Simulator or device.
autoAcceptAlerts Boolean Accept all iOS alerts automatically if they pop up. Default is false.
autoDismissAlerts Boolean Dismiss all iOS alerts automatically if they pop up. Default is false.
reuse Number 0: Launch the simulator and install the app. 1 (default): Uninstall the app and reinstall the app. 2: Only reinstall the app. 3: Keep the simulator and app after testing.

Android-only Capabilities

Key Type Description
package String Java package of the Android app you want to run.
activity String Activity name for the Android activity you want to launch from your package.
androidProcess String Process name for the chromedriver binding when test webview
isWaitActivity Boolean Wait the app’s main acitivity. Default is true.

iOS-only Capabilities

Key Type Description
bundleId String Bundle ID of the app such as

Electron-only Capabilities

Key Type Description
uesrAgent String A user agent originating the request.
extraHeaders String Extra headers separated by “\n”.

Puppeteer Capabilities

Key Type Description
uesrAgent String A user agent originating the request.


PC keycode

Android keycode


iOS keycode


Locator iOS Android PC
name label or value content-desc or rawtext element name
xpath xpath xpath xpath
class name class/type class element node name
id accessibility Id resource Id element id
css native unsupport native unsupport element css

Touch Gestures

Type Params Example Description
tap { x: 100, y: 100 } driver.touch(‘tap’, { x: 100, y: 100}) | element.touch(‘tap’) 点击某个坐标或者当前元素
doubleTap { x: 100, y: 100 } driver.touch(‘doubleTap’, { x: 100, y: 100}) | element.touch(‘doubleTap’) 双击某个坐标或者当前元素
press { x: 100, y: 100, duration: 2 (单位 S) } driver.touch(‘press’, { x: 100, y: 100}) | element.touch(‘press’, { duration: 2 }) 长按某个坐标或者当前元素
pinch { x: 100, y: 100,scale: 2 (iOS), velocity: 1(iOS), direction: “in” or “out”(Android), percent: 200(Android), duration: 2 (单位 S) } iOS: element.touch(‘pinch’, { scale: 2 }), Android: element.touch(‘pinch’, { direction: “in”, percent: 50 }) 两只手指放大或者缩小当前元素
rotate (iOS Only) { rotation: 6(弧度), velocity: 1 } element.touch(‘rotate’, { rotation: 6, velocity: 1 }) 旋转当前元素
drag { fromX: 100, fromY: 100, toX: 200, toY: 200, duration: 2(iOS,单位 S) } driver.touch(‘drag’, { fromX: 100, fromY: 100, toX: 200, toY: 200 }) | element.touch(‘drag’, { toX: 200, toY: 200 }) 拖拽一个元素或者在多个坐标之间移动


连续执行多个 touch 操作,类似于下图的密码解锁。

  type: 'drag',
  fromX: 265,
  fromY: 860,
  toX: 825,
  toY: 860,
  steps: 200
}, {
  type: 'drag',
  toX: 265,
  toY: 1460,
  duration: 3
}, {
  type: 'drag',
  toX: 825,
  toY: 1460,
  duration: 3