Description: Open a new window, then navigate to the new window from multiple windows
method one:
# Get multiple open window handles ' windows = driver.window_handles ' # switch to the most recently opened window driver.switch_to.window(windows[-1])
Method 2: Determine the window handle
# Get the handle of the first open window window_1 = driver.current_window_handle # Get all open window handles windows = driver.window_handles # switch to the newest window for current_window in windows: if current_window != window_1: driver.switch_to.window(current_window)