File tree Expand file tree Collapse file tree 1 file changed +26
-5
lines changed
Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,32 @@ def login():
5757 # Get all window handles
5858 all_windows = driver .window_handles
5959
60- print ("Find the new window" )
61- new_window = [window for window in all_windows if window != driver .current_window_handle ][0 ]
62-
63- print ("Switch to the new window" )
64- driver .switch_to .window (new_window )
60+ print ("Find the window with email input..." )
61+ new_windows = [window for window in all_windows if window != original_window ]
62+
63+ print (f"Found { len (new_windows )} new windows to check: { new_windows } " )
64+
65+ # Find the window with email input
66+ target_window = None
67+ for window in new_windows :
68+ try :
69+ print (f"Checking window: { window } " )
70+ driver .switch_to .window (window )
71+ driver .find_element (By .ID , ':r1:' )
72+ target_window = window
73+ print (f"Found email input in window: { window } " )
74+ break
75+ except :
76+ print (f"Email input not found in window: { window } , trying next..." )
77+ continue
78+
79+ if not target_window :
80+ print ("Could not find email input field in any window!" )
81+ driver .quit ()
82+ return
83+
84+ print ("Switch to the target window" )
85+ driver .switch_to .window (target_window )
6586
6687 wait = WebDriverWait (driver , 60 )
6788
You can’t perform that action at this time.
0 commit comments