Skip to content

[🐛 Bug]: unable to take screenshot using "saveScreenshot" inside an iframe #14065

@prabhakarankathir

Description

@prabhakarankathir

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest 9.5.3

Node.js Version

v20.15.1

Mode

Standalone Mode

Which capabilities are you using?

Running in Windows/Chrome browser
chrome version - 131.0.6778.205
Protocol: Webdriver BiDi

What happened?

After upgrading to webdriverIO 9, unable to take screenshot inside an iFrame using browser.saveScreenshot
I tried to use BiDi's "browsingContextCaptureScreenshot" but no matter what ever context ID i passed, it didn't work.

What is your expected behavior?

our application is wrapped inside an iframe, there is a workaround to use cdp to take screenshot, but sometimes getting target closed exception in after test.

How to reproduce the bug.

await browser.url('https://www.w3schools.com/html/html_iframe.asp');
await browser.pause(10000);//wait for it to load

    // // switch to a frame
    await browser.switchFrame($(`//iframe[@title='W3Schools HTML Tutorial']`));
    await browser.pause(3000);

    await $(`.w3-right.w3-btn`).click();

    await browser.pause(3000);

    await browser.saveScreenshot(`.testshot.png`);

Relevant log output

Error: WebDriver Bidi command "browsingContext.captureScreenshot" failed with error: unsupported operation - Non-top-level 'context' (4F8F8662A1A190C6542C420AD203A227) is currently not supported

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