Refactor exception handling in load_chromdriver_normal function in chrome_tixcraft.py for improved error reporting

master
Yong-Jer Chuang 2024-04-26 14:43:21 +08:00
parent fa575ceea4
commit 49723dd1e1
1 changed files with 3 additions and 3 deletions

View File

@ -338,7 +338,7 @@ def load_chromdriver_normal(config_dict, driver_type):
chrome_options = get_chrome_options(webdriver_path, config_dict) chrome_options = get_chrome_options(webdriver_path, config_dict)
try: try:
driver = webdriver.Chrome(service=chrome_service, options=chrome_options) driver = webdriver.Chrome(service=chrome_service, options=chrome_options)
except Exception as exc: except WebDriverException as exc:
error_message = str(exc) error_message = str(exc)
if show_debug_message: if show_debug_message:
print(exc) print(exc)
@ -360,12 +360,12 @@ def load_chromdriver_normal(config_dict, driver_type):
try: try:
chrome_options = get_chrome_options(webdriver_path, config_dict) chrome_options = get_chrome_options(webdriver_path, config_dict)
driver = webdriver.Chrome(service=chrome_service, options=chrome_options) driver = webdriver.Chrome(service=chrome_service, options=chrome_options)
except Exception as exc2: except WebDriverException as exc2:
print("Selenium 4.11.0 Release with Chrome For Testing Browser.") print("Selenium 4.11.0 Release with Chrome For Testing Browser.")
try: try:
chrome_options = get_chrome_options(webdriver_path, config_dict) chrome_options = get_chrome_options(webdriver_path, config_dict)
driver = webdriver.Chrome(service=Service(), options=chrome_options) driver = webdriver.Chrome(service=Service(), options=chrome_options)
except Exception as exc3: except WebDriverException as exc3:
print(exc3) print(exc3)
pass pass