switchFrame
Switches the active context to a frame, e.g. an iframe on the page. There are multiple ways you can query a frame on the page:
-
If given a string it switches to the frame with a matching context id, url or url that contains that string
// switch to a frame that has a specific url or contains a string in the url
await browser.url('https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe')
// Note: this frame is located in a nested iframe, however you only need to provide
// the frame url of your desired frame
await browser.switchFrame('https://www.w3schools.com')
// check the title of the page
console.log(await browser.execute(() => [document.title, document.URL]))
// outputs: [ 'W3Schools Online Web Tutorials', 'https://www.w3schools.com/' ]