fix: handle new-tab SSO redirect for MassHealth eligibility and history
After login, Chrome on some machines opens the portal dashboard in a new tab and closes the SSO tab. Poll all window handles until the portal URL is found, then switch to it — works for both same-tab and new-tab redirects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,30 @@ class AutomationMassHealthEligibilityHistoryCheck:
|
||||
)
|
||||
)
|
||||
login_button.click()
|
||||
|
||||
# Wait for the SSO redirect. On some machines Chrome opens the dashboard
|
||||
# in a new tab and closes the SSO tab — poll ALL window handles.
|
||||
print("[login] Waiting for SSO redirect to provider.masshealth-dental.org ...")
|
||||
deadline = time.time() + 30
|
||||
found = False
|
||||
while time.time() < deadline:
|
||||
time.sleep(0.5)
|
||||
for handle in self.driver.window_handles:
|
||||
try:
|
||||
self.driver.switch_to.window(handle)
|
||||
if self.driver.current_url.startswith("https://provider.masshealth-dental.org"):
|
||||
print(f"[login] Redirect complete. URL: {self.driver.current_url}")
|
||||
found = True
|
||||
break
|
||||
except Exception:
|
||||
continue
|
||||
if found:
|
||||
break
|
||||
|
||||
if not found:
|
||||
print("[login] Redirect timeout — portal window not found in any tab.")
|
||||
return "ERROR: Login redirect timed out — check credentials or portal availability."
|
||||
|
||||
return "Success"
|
||||
except Exception as e:
|
||||
print(f"[login] Error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user