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.
This commit is contained in:
kinoshitakenta 2025-06-12 16:26:41 +08:00
parent 6523fecb5a
commit 77054f1d84
Signed by: kinoshitakenta
GPG Key ID: A811E8CA36EF425E
1 changed files with 15 additions and 0 deletions

View File

@ -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 users 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])