fix: improve eligibility checks for MassHealth and DentaQuest

- MassHealth: detect SSO/portal maintenance page and return clear error
  instead of cryptic step1 timeout; wait for SSO redirect to complete
  before running step1; add modal dismissal and failure screenshot/logging
- DentaQuest: detect maintenance page in login and step1; search by
  member ID + DOB only (remove first/last name to prevent stale data
  from previous patient being submitted)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gitead
2026-05-19 23:05:48 -04:00
parent 95ce4c2fb4
commit 7284598c97
2 changed files with 98 additions and 33 deletions

View File

@@ -82,6 +82,21 @@ class AutomationDentaQuestEligibilityCheck:
print(f"[DentaQuest login] Error during forced logout: {e}")
return False
def _is_maintenance_page(self) -> bool:
"""Return True if the current page is DentaQuest's maintenance/capacity error page."""
try:
body = self.driver.find_element(By.TAG_NAME, "body").text
markers = [
"temporarily unable to service",
"maintenance downtime",
"capacity problems",
"Please try again later",
]
body_lower = body.lower()
return any(m.lower() in body_lower for m in markers)
except Exception:
return False
def login(self, url):
wait = WebDriverWait(self.driver, 30)
browser_manager = get_browser_manager()
@@ -114,7 +129,11 @@ class AutomationDentaQuestEligibilityCheck:
# Navigate to login URL
self.driver.get(url)
time.sleep(3)
if self._is_maintenance_page():
print("[DentaQuest login] Maintenance page detected")
return "ERROR: DentaQuest server is temporarily unavailable (maintenance). Please try again later."
current_url = self.driver.current_url
print(f"[DentaQuest login] After navigation URL: {current_url}")
@@ -264,7 +283,11 @@ class AutomationDentaQuestEligibilityCheck:
fields.append(f"LastName: {self.lastName}")
fields.append(f"DOB: {self.dateOfBirth}")
print(f"[DentaQuest step1] Starting member search with: {', '.join(fields)}")
if self._is_maintenance_page():
print("[DentaQuest step1] Maintenance page detected")
return "ERROR: DentaQuest server is temporarily unavailable (maintenance). Please try again later."
# Wait for page to be ready
time.sleep(2)
@@ -346,8 +369,7 @@ class AutomationDentaQuestEligibilityCheck:
fill_date_by_testid("member-search_date-of-birth", dob_month, dob_day, dob_year, "Date of Birth")
time.sleep(0.3)
# 3. Fill ALL available search fields (flexible search)
# Fill Member ID if provided
# 3. Fill Member ID only (search by member ID + DOB only)
if self.memberId:
try:
member_id_input = wait.until(EC.presence_of_element_located(
@@ -359,32 +381,6 @@ class AutomationDentaQuestEligibilityCheck:
time.sleep(0.2)
except Exception as e:
print(f"[DentaQuest step1] Warning: Could not fill member ID: {e}")
# Fill First Name if provided
if self.firstName:
try:
first_name_input = wait.until(EC.presence_of_element_located(
(By.XPATH, '//input[@placeholder="First name - 1 char minimum" or contains(@placeholder,"first name") or contains(@name,"firstName") or contains(@id,"firstName")]')
))
first_name_input.clear()
first_name_input.send_keys(self.firstName)
print(f"[DentaQuest step1] Entered first name: {self.firstName}")
time.sleep(0.2)
except Exception as e:
print(f"[DentaQuest step1] Warning: Could not fill first name: {e}")
# Fill Last Name if provided
if self.lastName:
try:
last_name_input = wait.until(EC.presence_of_element_located(
(By.XPATH, '//input[@placeholder="Last name - 2 char minimum" or contains(@placeholder,"last name") or contains(@name,"lastName") or contains(@id,"lastName")]')
))
last_name_input.clear()
last_name_input.send_keys(self.lastName)
print(f"[DentaQuest step1] Entered last name: {self.lastName}")
time.sleep(0.2)
except Exception as e:
print(f"[DentaQuest step1] Warning: Could not fill last name: {e}")
time.sleep(0.3)