Compare commits
3 Commits
51b18c6721
...
cd16467312
Author | SHA1 | Date | |
---|---|---|---|
cd16467312 | |||
e18d62d6bb | |||
c412fa1a80 |
@ -64,6 +64,24 @@ 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,
|
||||
|
Loading…
Reference in New Issue
Block a user