Skip to content

Switch Between IFrames

NaveenS edited this page Apr 18, 2020 · 2 revisions

IFrame

An IFrame (Inline Frame) is an HTML document embedded inside another HTML document on a website. The IFrame HTML element is often used to insert content from another source, such as an advertisement, into a Web page.

How to switch between IFrames.

If a web page contains multiple IFrames, then we will need to switch between them. You can switch through the following code snippet.

driver.switch_to.frame(frame_reference)

What is Frame Reference

frame_reference parameter is the locator used to identify the IFrame. Basically the name of the window to switch to, an integer representing the index, or a webelement that is an iframe to switch to.

Once you switch to IFrame then to move back to parent html you can use below method.

driver.switch_to.default_content()
Clone this wiki locally