Skip to content

[🐛 Bug]: browser.execute does not work on Perfecto mobile device #14841

@nheiser

Description

@nheiser

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.20.0

Node.js Version

v20.10.0

Mode

Standalone Mode

Which capabilities are you using?

{
    'perfecto:automationName': 'PerfectoMobile',
    'perfecto:platformName': 'iOS',
    'perfecto:model': 'iPhone-16',
    'perfecto:browserName': '',
    'perfecto:securityToken': "your security token"
}

What happened?

Perfecto automatically converts the command from browser.execute into one line. This means you must have proper semicolons in the command. In execute.ts, there is not a semicolon after webdriverioPolyfill(). This is causing the command to fail in Perfecto.

if (typeof script === 'function') {
    script = `
        ${polyfillFn}
        webdriverioPolyfill()
        return (${script}).apply(null, arguments)
    `
}

What is your expected behavior?

There should be a semicolon after webdriverioPolyfill()

if (typeof script === 'function') {
    script = `
        ${polyfillFn}
        webdriverioPolyfill();
        return (${script}).apply(null, arguments)
    `
}

How to reproduce the bug.

import { remote } from 'webdriverio'

const browser = await remote({
    loglevel: 'trace',
    hostname: 'your_cloud_name.perfectomobile.com',
    path: '/nexperience/perfectomobile/wd/hub',
    port: 443,
    protocol: 'https',
    capabilities: {
        'perfecto:automationName': 'PerfectoMobile',
        'perfecto:platformName': 'iOS',
        'perfecto:model': 'iPhone-16',
        'perfecto:browserName': '',
        'perfecto:securityToken': 'your security token'
    }
})

await browser.execute(() => {
    return 2 + 2;
});

Relevant log output

DEBUG webdriver: request failed due to status 13
WARN webdriver: WebdriverError: Failed to execute command webpage execute: executeScript command failed. Reason: handset server: timeout expired. when running "execute/sync" with method "POST" and args "() => {
    return 2 + 2;
}"

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions