diff --git a/utils/utils.py b/utils/utils.py index e94708b..9b64a5f 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -46,6 +46,21 @@ class LoginInfo(): def keep_login_status(driver: webdriver.Chrome, login_info: LoginInfo) -> bool: + """ + Attempt to log into the CHI MotorWeb ERP system using the provided login information. + + This function navigates to the login page, fills in the login form with the user’s credentials, + and attempts to log in. It handles unexpected alert pop-ups that indicate login failure, + and manages browser windows to ensure only the relevant page remains open. + + Args: + driver (webdriver.Chrome): An instance of Selenium WebDriver controlling a Chrome browser. + login_info (LoginInfo): A data object containing login credentials and preferences. + + Returns: + bool: True if login is successful or already logged in; False if login failed (e.g., due to incorrect credentials). + """ + # * Close all windows except the main window. while len(driver.window_handles) > 1: driver.switch_to.window(driver.window_handles[1])