diff --git a/run_window_v4.py b/run_window_v4.py index 58910ab..cc61854 100644 --- a/run_window_v4.py +++ b/run_window_v4.py @@ -64,6 +64,23 @@ port = config.get('WebSocket', 'port') sio.connect("ws://"+host+":"+port) # WebDriver初始化 def init_webdriver(driver_type): + # 先检查是否配置了自行安装的驱动 + try: + if driver_type.lower() == "edge" and driver_path_edge: # 只有在Edge类型且路径已知的情况下才尝试使用已存在的驱动 + edge_options = Options() # 创建Edge的Options实例 + service = Service(executable_path=driver_path_edge) # 使用已知的驱动路径 + driver = webdriver.Edge(service=service, options=edge_options) # 传入Options实例 + logging.info("使用自行安装的Edge") + return driver + elif driver_path_chrome: + edge_options = Options() # 创建Edge的Options实例 + service = Service(executable_path=driver_path_chrome) # 使用已知的驱动路径 + driver = webdriver.Edge(service=service, options=edge_options) # 传入Options实例 + logging.info("使用自行安装的Chrome") + return driver + except Exception as e: + logging.info("使用本地驱动失败,请先配置本地驱动。"+e.args[0]) + options = Options() manager = { "firefox": GeckoDriverManager,