Based on switchFrame()
WDIO docs,
the following should work:
await browser.switchFrame($('iframe'))
It's also proven by e2e test in main WDIO repository:
it('should reset the frame when the page is reloaded', async () => {
await browser.url('https://the-internet.herokuapp.com/iframe')
await expect($('#tinymce')).not.toBePresent()
await browser.switchFrame($('iframe'))
await expect($('#tinymce')).toBePresent()
await browser.refresh()
await expect($('#tinymce')).not.toBePresent()
await browser.switchFrame($('iframe'))
await expect($('#tinymce')).toBePresent()
})
However await browser.switchFrame($('iframe'))
construct
won't work with wdio-electron-service
unless $('iframe')
is await
ed.
This repo demonstrates the problem.
npm i
to resolve dependenciesnpm run package
to build an electron app displaying iframe from https://the-internet.herokuapp.com/iframenpm run wdio
to execute e2e test. It will fail ifswitchFrame()
argument is notawait
ed