npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wd-android

v0.1.1

Published

A wrapper for wd node package optimized for Android.

Downloads

37

Readme

wd-android

NPM version

A wrapper for wd node package optimized for Android to work with appium.io.

Install

npm install wd-android

Prerequisites

You need to install Appium.

You can install with npm:

npm install -g appium

or download it from appium website.

and then check if your ANDROID_HOME and JAVA_HOME are correctly.

You can achieve this by running:

$ appium-doctor --android
	Running Android Checks
	✔ ANDROID_HOME is set to "/path/to/android/sdk"
	✔ JAVA_HOME is set to "/path/to/java/sdk"
	✔ ADB exists at /sdk/platform-tools/adb
	✔ Android exists at /sdk/tools/android
	✔ Emulator exists at /sdk/tools/emulator
	✔ Android Checks were successful.

	✔ All Checks were successful

If you're usigin Android Studio and you have installed the sdk in Android Studio folder, may you need to run:

$ ln -s /path/to/Android Studio.app /path/to/AndroidStudioApp
$ export ANDROID_HOME=/path/to/AndroidStudioApp/sdk

Cause Appium doesn't work with spaces in ANDROID_HOME or JAVA_HOME paths.

Before start

Before launch your script with wd-android you need to run the appium server. It's quite simple:

$ appium

Usage

How to instantiate:

var wd = require('wd'),	
	WdAndroid = require('wd-android');

var wdAndroid = new WdAdndroid(wd);

var driver = wdAndroid.promiseChainRemote();

driver.init().setImplicitWaitTimeout(10000);
driver
	.viewPagerElement()
	.swipe({
		startX: 0.9,
		startY: 0.5,
		endX: 0.1,
		endY: 0.5,
		duration: 800
	})
   .waitForLinearLayout()
   .click();

Api

More friendly methods to referer to Android Elements than by XPath.

// driver.elementByXPath('//android.widget.FrameLayout')
driver.frameLayoutElement();

// driver.elementByXPath('//android.widget.LinearLayout')
driver.linearLayoutElement();

// driver.elementByXPath('//android.widget.ListView')
driver.listViewElement();

// driver.elementByXPath('//android.view.support.v4.ViewPager)
driver.viewPagerElement();

// driver.elementByXPath('//android.webkit.WebView)
driver.webViewElement();

Simple Id

Pass the default package as secondo arguments in wd-android constructor to find element by their simple ids.

// wd way
driver.elementById('com.example.app:id/productsList');

// wd-android way
var wdAndroid = new WdAndroid(wd, 'com.example.app');
...
...
driver.elementBySimpleId('productsList')

Sub-elements Reference

Access the sub-elements by passing parent element id.

N.B.: The original wd module hasn't this feature.

And yes, you can use the simple elements ids.

driver
	.frameLayoutChildren('com.example.app:id/viewPager')
	.then(function(els) {
		return els[1].click();
	})
	// with simple id
	.linearLayoutChildren('productList')
	.then(function(els) {
		return els[1].click();
	});

Alerts

Access the alert dialog showed without pain.

driver.elementBySimpleId('takeButtonBox')
	.click()
   .shouldAppearAlertElement()
   .positiveAlertButton()
   .text()
   		.should.become.eql("Ok")
   .negativeAlertButton()
   .text()
   		.should.become.eql("Cancel");

Mobile Gestures

Built in methods to perform mobile gestures.

// perform swipe from 90% of the screen width to 10%

driver.swipe({
	startX: 0.9,
	startY: 0.5,
	endX: 0.1,
	endY: 0.5,
	duration: 800
});
Mobile Gestures for specific element

// swipe element
driver
	.elementById('com.example.app:id/loginButton')
	.swipeElement({
		startX: 0.9,
		startY: 0.5,
		endX: 0.1,
		endY: 0.5,
		duration: 800
});

// tap element

driver
	.elementById('com.example.app:id/loginButton')
	.tapElement({
		x: 0.9,
		y: 0.5
});

Should integration


// wd way
driver.
	.elementById('com.example.app:id/loginButton')
	.then(function(el) {
		return el.getTagName(function(err, name) {
			return name;
		});
	}).then(function(name){
		return name.should.be.eql('android.widget.Button')
	});

// wd-android way
driver
	.elementById('com.example.app:id/loginButton')
	.shouldBeButtonElement()

Mocha Integration


var path = require('path'),
	wd = require('wd'),
	WdAndroid = require('wd-android');

var appiumServer = {
    host: 'localhost',
    port: 4723
};

var android19 = {
    browserName: '',
    'appium-version': '1.2.2',
    platformName: 'Android',
    platformVersion: '4.4.2',
    deviceName: 'Android Emulator',
    app: undefined
};

var androidDebugApp = '../path/to/your/apk';

describe("Using Appium and WdAndroid to test Android App.", function(){
	this.timeout(300000);
    var driver,
   		allPassed = true;

    before(function() {

        var wdAndroid = new WdAndroid(wd);

        driver = wdAndroid.promiseChainRemote(appiumServer);
        
        var desired = android19;
        
        desired.app = path.resolve(__dirname, androidDebugApp);

        return driver
        			.init(desired)
        			.setImplicitWaitTimeout(10000);
    });


    after(function() {
        return driver.quit();
    });


    afterEach(function() {
        allPassed = allPassed && this.currentTest.state === 'passed';
    });


    it("shoul find an element", function() {
        return driver
            .viewPagerElement()
            .swipe({
                startX: 0.9,
                startY: 0.5,
                endX: 0.1,
                endY: 0.5,
                duration: 800
            })
            .waitForLinearLayout()
            .click();

    });
});