Getting TypeError: Object has no member 'contentFrame' after migrating browser scripts to k6 v0.52

Hello,

I am getting the following error after I migrate my browser test script into k6 v0.52
ERRO[0007] Uncaught (in promise) TypeError: Object has no member ‘contentFrame’

async _clickCaptcha() {
    const iframeHandle = this.page.waitForSelector('//iframe[@title="reCAPTCHA"]', { state: 'visible' });
    const frame = iframeHandle.contentFrame();
    const button1 = frame.waitForSelector('#recaptcha-anchor');
    await button1.dispatchEvent('click');
    await button1.waitForElementState('checked');
}

getting the error for the following line:
const frame = iframeHandle.contentFrame();

This code is working for ‘k6/experimental/browser’

Hi @meteboyaci11,

The k6/browser is now fully async. As explained in this migration document and also in the k6 browser documentation, you need use await for waitForSelector and contentFrame.

I hope this helps.

Hi @inancgumus
Yes it worked after adding await for waitForSelector and contentFrame. Thank you very much for your help.

Regards.

2 Likes