Naughty Pterodactyl Maid

    appium-dom-utils
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.6 • Public • Published

    Installation

    NPM Version NPM DownloadsLicense

    npm i -S appium-dom-utils
    

    appium-dom-utils

    A collection of util functions for writing Appium tests using DOM API.

    const {
      parseDomFromString,
      getXPathSelector,
    } = require('appium-dom-utils');
    const wdio = require("webdriverio");
     
    const client = await webdriverio.remote(opts);
    const xmlSourceString = await client.getPageSource();
    const dom = parseDomFromString(xmlSourceString);
    const domElement = dom.querySelector("[text*='9']");
    const xpath = getXPathSelector(domElement);
    const appiumElement = await client.$(xpath);
    await appiumElement.click();
    await client.deleteSession();

    API

    parseDomFromString(xml: String)

    Returns a DOM object. Throws when the xml string is not formatted well. Currently tested with the return value of driver.getPageSource() for both Android (UiAutomator2) and iOS (UIAutomation) tests.

    import { parseDomFromString } from 'appium-dom-utils';
    parseDomFromString(xmlString);

    getXPathSelector(el: Element)

    Returns the xpath (string) for the element supplied. [Android UiAutomator2 tests].

    import { getXPathSelector } from 'appium-dom-utils';
    getXPathSelector(element);

    getClassChainSelector(el: Element)

    Returns the class chain (string) for the element supplied. [iOS UIAutomation tests].

    import { getClassChainSelector } from 'appium-dom-utils';
    getClassChainSelector(element);

    Keywords

    Install

    npm i appium-dom-utils

    DownloadsWeekly Downloads

    11,062

    Version

    1.0.6

    License

    MIT

    Unpacked Size

    2.42 MB

    Total Files

    8

    Last publish

    Collaborators

    • rannn505