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 awaited.
This repo demonstrates the problem.
npm ito resolve dependenciesnpm run packageto build an electron app displaying iframe from https://the-internet.herokuapp.com/iframenpm run wdioto execute e2e test. It will fail ifswitchFrame()argument is notawaited