Skip to content

Commit 5bdd53c

Browse files
committed
test: fix windows login tab
1 parent 803d8c1 commit 5bdd53c

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

sample/Tests/test/test_windows_helpers.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,30 @@ def login():
5656

5757
# Get all window handles
5858
all_windows = driver.window_handles
59-
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)
59+
60+
print(f"Found {len(all_windows)} new windows to check: {all_windows}")
61+
62+
# Find the window with email input
63+
target_window = None
64+
for window in all_windows:
65+
try:
66+
print(f"Checking window: {window}")
67+
driver.switch_to.window(window)
68+
driver.find_element(By.ID, ':r1:')
69+
target_window = window
70+
print(f"Found email input in window: {window}")
71+
break
72+
except:
73+
print(f"Email input not found in window: {window}, trying next...")
74+
continue
75+
76+
if not target_window:
77+
print("Could not find email input field in any window!")
78+
driver.quit()
79+
return
80+
81+
print("Switch to the target window")
82+
driver.switch_to.window(target_window)
6583

6684
wait = WebDriverWait(driver, 60)
6785

@@ -126,8 +144,9 @@ def bring_sample_app_to_foreground():
126144

127145
command = [
128146
"powershell.exe",
129-
"-Command",
130-
f"Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process; & '{powershell_script_path}' -appName '{product_name}'"
147+
"-ExecutionPolicy", "Bypass",
148+
"-File", powershell_script_path,
149+
"-appName", product_name
131150
]
132151

133152
subprocess.run(command, check=True)

0 commit comments

Comments
 (0)