From 0b3cc241bf3aaf1f5a0bef3acaa37701d2daa7a4 Mon Sep 17 00:00:00 2001 From: Gitead Date: Wed, 27 May 2026 23:30:00 -0400 Subject: [PATCH] fix: broaden XPath for United SCO Select Insurance OK button Use normalize-space(.) instead of text() to capture button text inside child elements, add modal-scoped fallback selectors, and prefer JS click to avoid overlay interception. Co-Authored-By: Claude Sonnet 4.6 --- .../selenium_UnitedSCO_eligibilityCheckWorker.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/SeleniumService/selenium_UnitedSCO_eligibilityCheckWorker.py b/apps/SeleniumService/selenium_UnitedSCO_eligibilityCheckWorker.py index 8f5740cb..cd58f659 100644 --- a/apps/SeleniumService/selenium_UnitedSCO_eligibilityCheckWorker.py +++ b/apps/SeleniumService/selenium_UnitedSCO_eligibilityCheckWorker.py @@ -675,14 +675,22 @@ class AutomationUnitedSCOEligibilityCheck: # Step 1.4: Click OK on "Select Insurance" popup print("[UnitedSCO step1] Checking for 'Select Insurance' popup...") try: + # Use normalize-space(.) instead of text() to capture text in child elements (e.g. Ok) + # Also broaden match: no @type or @class requirement in case they differ ok_btn = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable((By.XPATH, - "//button[@type='button' and contains(@class,'btn-primary') and " - "(normalize-space(text())='Ok' or normalize-space(text())='OK')]" + "//button[contains(@class,'btn-primary') and " + "(normalize-space(.)='Ok' or normalize-space(.)='OK' or normalize-space(.)='Okay')] | " + "//modal-container//button[normalize-space(.)='Ok' or normalize-space(.)='OK' or normalize-space(.)='Okay'] | " + "//div[contains(@class,'modal')]//button[normalize-space(.)='Ok' or normalize-space(.)='OK' or normalize-space(.)='Okay']" )) ) - ok_btn.click() - print("[UnitedSCO step1] Clicked OK on Select Insurance popup") + try: + self.driver.execute_script("arguments[0].click();", ok_btn) + print("[UnitedSCO step1] Clicked OK on Select Insurance popup (JS)") + except Exception: + ok_btn.click() + print("[UnitedSCO step1] Clicked OK on Select Insurance popup (direct)") # Wait for the modal to disappear before moving on try: WebDriverWait(self.driver, 10).until(