1

So, I'm working on a Selenium webdriver Project, and, in one of the process, I needed to enter in na iframe, and then, send Keys to the input in there, but, now I want to close or exit that iframe to can click in a button outside that frame, check out me code piece:

WebDriverWait(bot,20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe.top[title='Registration form']")))
WebDriverWait(bot, 20).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="username"]'))).send_keys(self.usernameChar)
WebDriverWait(bot, 20).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="username"]'))).send_keys(Keys.RETURN)

Can you guys help me? Note: My google version is the 85

1 Answers1

2

To exit from any <iframe> and set Selenium's focus on the Top Browsing Context you can use the following line of code:

driver.switch_to.default_content()

Reference

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352