Compare commits
2 Commits
2c5ca3c3d3
...
e1ec580ce1
Author | SHA1 | Date |
---|---|---|
|
e1ec580ce1 | |
|
5b87c86223 |
5
main.py
5
main.py
|
@ -4,6 +4,7 @@
|
||||||
__author__ = 'kinoshitakenta'
|
__author__ = 'kinoshitakenta'
|
||||||
__email__ = "ybs0306748@gmail.com"
|
__email__ = "ybs0306748@gmail.com"
|
||||||
|
|
||||||
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -51,6 +52,7 @@ def display_usage():
|
||||||
clear_screen()
|
clear_screen()
|
||||||
for cmd, msg in get_usage():
|
for cmd, msg in get_usage():
|
||||||
print(f"{cmd}: {msg}")
|
print(f"{cmd}: {msg}")
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
def main(opt):
|
def main(opt):
|
||||||
|
@ -62,11 +64,12 @@ def main(opt):
|
||||||
login_info = LoginInfo(config_path)
|
login_info = LoginInfo(config_path)
|
||||||
|
|
||||||
driver = get_driver()
|
driver = get_driver()
|
||||||
keep_login_status(driver, login_info)
|
|
||||||
action_agent = Action(driver)
|
action_agent = Action(driver)
|
||||||
|
|
||||||
display_usage()
|
display_usage()
|
||||||
|
|
||||||
|
keep_login_status(driver, login_info)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
cmd = input("\nInput action code: ").strip()
|
cmd = input("\nInput action code: ").strip()
|
||||||
|
|
|
@ -8,7 +8,7 @@ if sys.version_info >= (3, 11):
|
||||||
else:
|
else:
|
||||||
import tomli as tomllib
|
import tomli as tomllib
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.common.exceptions import NoAlertPresentException, UnexpectedAlertPresentException
|
from selenium.common.exceptions import NoAlertPresentException, NoSuchWindowException, UnexpectedAlertPresentException
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
from selenium.webdriver.support.ui import Select
|
from selenium.webdriver.support.ui import Select
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ def keep_login_status(driver: webdriver.Chrome, login_info: LoginInfo) -> bool:
|
||||||
print(f"Login error message: {alert.text}")
|
print(f"Login error message: {alert.text}")
|
||||||
alert.accept()
|
alert.accept()
|
||||||
return False # Skip remaining logic, login failed
|
return False # Skip remaining logic, login failed
|
||||||
except NoAlertPresentException:
|
except (NoAlertPresentException, NoSuchWindowException):
|
||||||
pass # No alert, proceed
|
pass # No alert, proceed
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
@ -119,7 +119,7 @@ def keep_login_status(driver: webdriver.Chrome, login_info: LoginInfo) -> bool:
|
||||||
print(f"Unexpected alert: {alert.text}")
|
print(f"Unexpected alert: {alert.text}")
|
||||||
alert.accept()
|
alert.accept()
|
||||||
continue
|
continue
|
||||||
except NoAlertPresentException:
|
except (NoAlertPresentException, NoSuchWindowException):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if "CHI MotorWeb - " in title:
|
if "CHI MotorWeb - " in title:
|
||||||
|
|
Loading…
Reference in New Issue