Handling Iframes In Selenium (Java)

Handling Iframes In Selenium (Java)

Often Website will use Iframes to contain some elements in a way which makes finding said elements difficult in a Selenium test. To switch the drivers focus to an Iframe you need to use driver.switchTo().frame(identifier) where the identifier is either the index, name or ID of the iframe.

To show this in an example here is a code snippet:


//This element is not visible unless the iframe has been switched to

Leave a reply

Your email address will not be published. Required fields are marked*

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.