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 🙏

© 2024 – Pkg Stats / Ryan Hefner

wdio-mobile-utils

v8.0.2

Published

A cross-platform mobile end-to-end testing library for WebdriverIO.

Downloads

1,792

Readme

Install

Releases for WebdriverIO v5 are released on the v5 branch, while releases for WebdriverIO v6 are releases on the master branch.

Check the releases here, the releases for WebdriverIO v6 are prefixed with 6-, while releases for WebdriverIO v5 are prefixed with 5-.

npm install -D [email protected]          # WebdriverIO v6
npm install -D [email protected]          # WebdriverIO v5

Table of Contents

TSDoc

You can find documentation for the individual methods here: https://martinfrancois.github.io/wdio-mobile-utils/

Mobile Selectors

In cases where you cannot use accessibilityIds, it is recommended to use ios predicate for iOS and UiSelector for Android. wdio-mobile-utils provides an abstraction to build mobile selectors easily which are cross-platform. This means you can build your selectors using mobile$ and mobile$$ and wdio-mobile-utils will automatically convert this into an ios predicate for iOS and UiSelector for Android for you automatically, depending on which platform the test is running on.

To select one element, use mobile$, which is the equivalent to $ in WebdriverIO. To select all elements use mobile$$, which is the equivalent to $$ in WebdriverIO.

You can find all of the different Selectors you can use in the TSDoc for Selector.

For example, to select a button which works on both Android and iOS, we can use the following selector with wdio-mobile-utils:

mobile$(Selector.type(Type.BUTTON));

Internally, it will convert this into the following ios predicate and UiSelector selectors, depending on the platform the test is running on:

// UiSelector
$('android=new UiSelector().className("android.widget.Button")');

// ios predicate
$("-ios predicate string:type == 'XCUIElementTypeButton'");

Combining selectors

You can also use multiple selectors together, combining them either with an AND (&&) or an OR (||) condition:

Selector.and(selector1, selector2); // AND (&&) condition
Selector.or(selector1, selector2); // OR (||) condition

For example, to select a button with the text Login which works on both Android and iOS, we can use the following selector with wdio-mobile-utils:

// compact form
mobile$(Selector.and(Selector.type(Type.BUTTON), Selector.text('Login')));

// long form
mobile$(
    Selector.and(
       Selector.type(Type.BUTTON),
       Selector.text('Login')
    )
);

Internally, it will convert this into the following ios predicate and UiSelector selectors, depending on the platform the test is running on:

// UiSelector
$('android=new UiSelector().className("android.widget.Button").text("Login")');

// ios predicate
$("-ios predicate string:type == 'XCUIElementTypeButton' && label == 'Login'");

Custom Selectors

If you can't find a selector you're looking for, if it's generic enough to be useful for others, consider contributing with a PR here.

If you need to use a very specific selector or one that may only work on one platform and you still want to make use of the easy fluent API of wdio-mobile-utils, you can use a custom selector.

For example:

mobile$(
    Selector.custom(
        AndroidSelector.of(ANDROID_UISELECTOR_PROPERTIES.RESOURCE_ID, 'URL'),
        IosSelector.of(IOS_PREDICATE_ATTRIBUTES.VALUE, IOS_PREDICATE_COMPARATOR.EQUALS, 'URL')
    )
);

To create a selector which only works on one platform, set one of the selectors to null, like so:

mobile$(
    Selector.custom(
        null, // no selector on Android
        IosSelector.of(IOS_PREDICATE_ATTRIBUTES.RECT, IOS_PREDICATE_COMPARATOR.EQUALS, 'URL')
    )
);

Note that when creating a selector which only works on one platform (for example, only for iOS), if a test is executed on the other platform (for example, Android), it will throw an error. This also applies in cases where a selector which only works on one platform is combined with a cross-platform selector, which is used on the other platform.

Usage in Action

Check out the recording and the slides of my presentation at SauceCon Online 2020 for detailed information on how to use the library.