From bb1677730409dd08691ceb730c63fbcf97f313a4 Mon Sep 17 00:00:00 2001 From: Potenz Date: Tue, 1 Jul 2025 08:26:59 +0530 Subject: [PATCH] alert fixed --- apps/SeleniumService/selenium_worker.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/SeleniumService/selenium_worker.py b/apps/SeleniumService/selenium_worker.py index c824d9f..e795ff2 100644 --- a/apps/SeleniumService/selenium_worker.py +++ b/apps/SeleniumService/selenium_worker.py @@ -287,8 +287,20 @@ class AutomationMassHealth: close_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@type='submit' and @value='Submit Request']"))) close_button.click() - time.sleep(3) - + time.sleep(1) + + # Switch to alert and accept it + try: + wait.until(EC.alert_is_present()) + + alert = self.driver.switch_to.alert + alert.accept() + print("Alert accepted.") + except TimeoutException: + print("No alert appeared after clicking the button.") + + time.sleep(1) + except Exception as e: print(f"Error while Closing: {e}") return "ERROR:CLOSE FAILED"