O'Reilly logo

Selenium Essentials by Prashanth Sams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling iframes

A web page can have any number of iframes (inline frames) to represent new pages inside a main page. They can be either multiple iframes or nested iframes. The iframes are indicated with an iframe tag, such as <iframe>...</iframe>.

It's easy to handle iframes when a user discovers all the iframes available in a web page. Google Chrome's Developer debugging tool is used to check the availability of iframes. The following figure is an example of nested iframes:

Handling iframes

To handle iframes, it's important to switch into and move out of an iframe to the main frame. The following is the syntax for switching iframes:

driver.switchTo().frame()

The following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required