selenium设置默认下载路径及禁止弹窗
函数网上搜集,亲测有效import os
def set_download_path(driver, path):
"""
禁止下载弹窗,设置下载路径
"""
path = path.rstrip(os.sep)
driver.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command')
params = {'cmd': 'Page.setDownloadBehavior',
'params': {'behavior': 'allow', 'downloadPath': path}}
driver.execute("send_command", params)
if not os.path.exists(path):
os.makedirs(path) 感谢分享! 学习了! 谢谢鱼币
页:
[1]