switch_to_default_content() will bring you back to the beginning of the document. What happens is that you switched to the first iframe , returned to the beginning of the document, and then tried to find the second iframe . Selenium cannot find the second iframe because it is inside the first iframe .
If you remove the second switch_to_default_content() , you should be fine:
iframe = driver.find_elements_by_tag_name('iframe')[0] driver.switch_to_default_content() driver.switch_to_frame(iframe) driver.find_elements_by_tag_name('iframe')[0]
source share