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(