Article From:https://www.cnblogs.com/hao2018/p/9641948.html

iframe(locatorThere are three scenarios: the driver. find_element_by_xpath()), the name of the frame, and the subscript index.

driver.switch_to.frame(locator)   #Switch iframe

driver.switch_to.parent_frame()  #This method is suitable for nested iframe. When you have a parent iframe and a child iframe, then your current location is a child iframe. If you want to switch back to the parent iframe, you need to use switch_to..parent_frame() ,Back to parent iframe

driver.switch_to.default_content()  #Back to the outermost HTML

 

Waiting method can switch iframe automatically

WebDriverWait(driver,20,1).until(EC.frame_to_be_available_and_switch_to_it(ele))

Link of this Article: Iframe switching

Leave a Reply

Your email address will not be published. Required fields are marked *