How to use the webdriverio.ErrorHandler function in webdriverio

To help you get started, we’ve selected a few webdriverio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webdriverio / webdriverrtc / lib / startAnalyzing.js View on Github external
export default async function startAnalyzing (selectorMethod = () => false) {
    if (this.analyzingScriptIsInjected) {
        throw new ErrorHandler('CommandError', 'analyzing already started')
    }

    await this.browser.timeouts('script', 1000)
    let res = await this.browser.selectorExecuteAsync(
        'body',
        startAnalyzingScript,
        selectorMethod,
        this.interval
    )

    if (!res || Object.keys(res).length === 0) {
        throw new ErrorHandler('CommandError', 'WebRTC connection didn\'t get established')
    }

    const ipAddressLocal = res.local.ipAddress.split(/:/)
    const ipAddressRemote = res.remote.ipAddress.split(/:/)

    res.local.ipAddress = ipAddressLocal[0]
    res.local.port = ipAddressLocal[1]
    res.remote.ipAddress = ipAddressRemote[0]
    res.remote.port = ipAddressRemote[1]

    this.connection = res
    this.analyzingScriptIsInjected = true
    return this.connection
}
github webdriverio / webdriverrtc / lib / startAnalyzing.js View on Github external
export default async function startAnalyzing (selectorMethod = () => false) {
    if (this.analyzingScriptIsInjected) {
        throw new ErrorHandler('CommandError', 'analyzing already started')
    }

    await this.browser.timeouts('script', 1000)
    let res = await this.browser.selectorExecuteAsync(
        'body',
        startAnalyzingScript,
        selectorMethod,
        this.interval
    )

    if (!res || Object.keys(res).length === 0) {
        throw new ErrorHandler('CommandError', 'WebRTC connection didn\'t get established')
    }

    const ipAddressLocal = res.local.ipAddress.split(/:/)
    const ipAddressRemote = res.remote.ipAddress.split(/:/)
github webdriverio / webdriverrtc / lib / getConnectionInformation.js View on Github external
export default function getConnectionInformation () {
    if (!this.connection) {
        throw new ErrorHandler('CommandError',
            'No information got recoreded yet. Please run the startAnalyzing command first'
        )
    }

    return this.connection
};
github webdriverio / webdriverrtc / lib / getStats.js View on Github external
const rawData = []
    let from = now
    let to = now

    if (typeof duration === 'number') {
        from = now - duration
        to = now
    } else if (typeof duration === 'object' && typeof duration.from === 'number' && duration.to === 'number') {
        from = duration.from
        to = duration.to
    }

    const stats = (await this.browser.execute(getStatsScript, from, to, this.interval)).value

    if (!stats) {
        throw new ErrorHandler('CommandError', 'There was a problem receiving the results')
    }

    stats.forEach((result, i) => {
        rawData.push(result.results)
        delete stats[i].results
    })

    if (stats.length === 1) {
        return stats[0]
    }

    let mean = calcResult['+'](stats)
    mean = calcResult['/'](mean, stats.length)

    let median = calcResult['[]'](stats)
    median = calcResult['-|-'](median)

webdriverio

Next-gen browser and mobile automation test framework for Node.js

MIT
Latest version published 14 days ago

Package Health Score

94 / 100
Full package analysis