1.1 Multi-form switching
driver.switch_to.frame(''if) #Switch to the iframe whose id is if, where id or name can be written directly
If there is no id or name, you can locate the iframe through xpath or css, and then switch
Return to the parent form: driver.switch_to.parent_content()
Return to the outermost form: driver.switch_to.default_content()
1.2 Multi-window switching
Get handle: handle1 = driver.current_window_handle
Get all page handles: all_handles = driver.window_handles
driver.switch_to.window (handle to be switched), generally entered by judging that it is not equal to the current handle
1.3 Warning box processing
In web applications, there are often many alert, confirm and prompt pop-ups written in JavaScript, which requires driver.switch_to_alert() to select (locate) the warning pop-ups. Then close the pop-up window, enter information and other methods to operate.
u getText(): Returns the text information in alert/confirm/prompt.
u accept(): Accept the existing alert box. Click [Confirm]
u dismiss(): dismiss the existing alert box. Click [Cancel]
u sendKeys(keysToSend): Send text to the alert box.
u keysToSend: Send text to alert box.
Such as: driver.switch_to_alert().accept() #Accept the warning box