Selenium and iframe in html

driver.switch_to.frame(driver.find_element_by_tag_name("iframe")) assuming that driver is a healthy instance of webdriver. To continue with the default content do driver.switch_to.default_content()

EDIT: When you have switched to needed frame, locate your webelement as you always do. I guess (but not sure) in your case this will be a html/body, so

el = driver.find_element_by_xpath('html/body')

should be fine. And perform

el.send_keys('keys_to_send')

EDIT2: Before sending keys you may have to focus on the element (click should do the thing, a child element should appear). Or you can just place the needed text via JS.

driver.execute_script('document.body.innerHTML = "%s"' % text_var)

Leave a Comment