From 77054f1d840bc1560dead2407375225618e223bf Mon Sep 17 00:00:00 2001 From: kinoshitakenta Date: Thu, 12 Jun 2025 16:26:41 +0800 Subject: [PATCH] docs: adds documentation to login function Adds a detailed docstring to the `keep_login_status` function, clarifying its purpose, arguments, return value, and behavior during login attempts. --- utils/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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])