From fe42d3cd98dc52ed83349b1572d59d5441e06b0e Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Mon, 26 Jan 2026 16:10:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(AutoLib):=20=E4=BF=AE=E5=A4=8D=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E9=A9=B1=E5=8A=A8=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/operators/AutoLib.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/operators/AutoLib.py b/src/operators/AutoLib.py index 741e7df..f2f3f18 100644 --- a/src/operators/AutoLib.py +++ b/src/operators/AutoLib.py @@ -64,7 +64,8 @@ class AutoLib(MsgBase): case "firefox": driver_options = webdriver.FirefoxOptions() case _: - raise Exception(f"不支持的浏览器驱动类型: {self.__driver_type} !") + self._showTrace(f"不支持的浏览器驱动类型: {self.__driver_type} !") + return False if not web_driver_config: self._showTrace("未配置浏览器驱动参数 !") @@ -107,7 +108,8 @@ class AutoLib(MsgBase): # init browser driver self.__driver_path = web_driver_config.get("driver_path") if not self.__driver_path: - raise Exception(f"未配置浏览器驱动路径 !") + self._showTrace("未配置浏览器驱动路径 !") + return False self.__driver_path = os.path.abspath(self.__driver_path) try: service = None @@ -122,7 +124,8 @@ class AutoLib(MsgBase): self._showTrace(f"Firefox 浏览器驱动初始化略慢, 请耐心等待...") service = FirefoxService(executable_path=self.__driver_path) self.__driver = webdriver.Firefox(service=service, options=driver_options) - case _: + case _: # actually will not happen, beacuse we have checked it at the initlization + # of 'driver_options' raise Exception(f"不支持的浏览器驱动类型: {self.__driver_type}") self.__driver.implicitly_wait(1) self.__driver.execute_script(