Switch to an iframe through Selenium and python

You can use an XPath to locate the <iframe>:

iframe = driver.find_element_by_xpath("//iframe[@name="Dialogue Window"]")

Then switch_to the <iframe>:

driver.switch_to.frame(iframe)

Here’s how to switch back to the default content (out of the <iframe>):

driver.switch_to.default_content()

Leave a Comment