base_handle = browser.current_window_handle
#some action to open another window
if len(browser.window_handles) == 2:
new_window_handle = browser.window_handles[1]
Now when I print both of these handles, it works great most of the time, however, once in a while the handles are same for both windows. And I am not able to solve it. Let me know if I need to share more