goharanwar / uiautomator

Light weight and robust NodeJS wrapper for UIAutomator2 with built-in server for device
MIT License
13 stars 3 forks source link

uiautomator

Codacy Badge Build Status npm version GitHub issues GitHub stars GitHub license Greenkeeper badge

Light weight and robust NodeJS wrapper for UIAutomator2 with builtin server for device. It works on Android 4.1+ simply with Android device attached via adb, no need to install anything on Android device.

Note: This module is using UIAutomator version 2.1.3

Installation

npm install uiautomator-server

Usage

const UIAutomator = require('uiautomator-server');

const device = new UIAutomator();
await device.connect();
await device.click({description: 'Apps'});
const deviceInfo = await device.info();
console.log(deviceInfo);

Device setup

const UIAutomator = require('uiautomator-server');
const options = {
    serial: '192.168.57.101:5555'
}

const device = new UIAutomator(options);
await device.connect(); // This will start the uiautomator server on device. Now you can continue calling the api

Default options

These are the default options. You can override them as needed

{
    hostname: 'localhost',
    commandsExecutionDelay: 10, //Delay between commands in ms
    port: 9008,
    devicePort: 9008,
    connectionMaxTries: 5,
    connectionTriesDelay: 1000, // In ms
    serial: undefined //Not necessary if there is only one device available
}

API

Notes

Acknowledgement

This package is inspired by xiaocong/uiautomator.