Selenium-5 multi-window switching
# search 51cto from Baidu and go to the home page of 51cto College
From selenium import webdriver
B = webdriver.Firefox ()
B.get ("http://baidu.com")"
Ele = b.find_element_by_id ("kw")
Ele.send_keys ("51cto")
Ele.click ()
B.find_element_by_partial_link_text ("IT system training leaders"). Click ()
B.window_handles
B.current_window_handle
B.switch_to_window (b.window_handles [1])
B.current_windows_handle # displays the current handle, in this case, the window in which it is located
B.window_handles # lists all handles, in this case, all open browser windows
B.switch_to_window # switch handle, in this case, toggle window
B.current_url # shows the current handle link
B.switch_to_window (b.window_handles [1]) # switch to 51cto window
B.switch_to_window (b.window_handles [0]) # switch to Baidu search results window