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 <noreply@anthropic.com>
This commit is contained in:
@@ -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. <span>Ok</span>)
|
||||
# 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']"
|
||||
))
|
||||
)
|
||||
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")
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user