Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: elem[prop] is not a function in Webdriveio

TypeError: elem[prop] is not a function

E2E testing in webdriveio. I want to click a button inside an iframe.

let iframe = browser.$('#fullmessage')
        browser.pause(1000)
        browser.switchToFrame(iframe)
        browser.setTimeout({ implicit: 10000 })
        let clickAgree = $('a[class="button is-success"]')
        clickAgree.click()
        browser.switchToParentFrame()
        browser.pause(3000)
like image 444
Amer Gaber Avatar asked Sep 18 '26 17:09

Amer Gaber


1 Answers

Hi i faced with the same problem, but in async. The reason is that you need to await already defined element as parameter: get iframe() { return $('.iframe'); }

await browser.switchToFrame(await this.iframe); Because switchToFrame works only with element, not with promise. Maybe for someone it will be useful.

like image 83
Green Green4 Avatar answered Sep 20 '26 07:09

Green Green4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!