Оптимизированы записи параметров для модулей python/selenium.

    options = webdriver.ChromeOptions()
    options.add_argument("--disable-notifications") # 禁用Chrome浏览器的通知,避免自动化测试过程中出现弹框干扰
    options.add_argument("--disable-extensions")    # 禁用Chrome浏览器的扩展插件功能,避免插件对自动化测试造成干扰。
    options.add_argument("--disable-gpu")           # 禁用GPU加速
    options.add_argument('--incognito')             # 不显示图片,隐身模式(无痕模式)
    options.add_argument("--no-sandbox")            # 禁用Chrome浏览器的沙箱
    options.add_argument("--headless=new")          # 使用headless模式
    options.headless = True                         # 启用无头浏览器
    options.add_argument('log-level=3')             # 设置浏览器的日志级别为 error,只输出错误级别及以上的日志
    options.add_argument('--disable-plugins')       # 禁用浏览器中的插件,以提高浏览器性能和安全性
    options.page_load_strategy = 'eager'
    options.add_argument('blink-settings=imagesEnabled=false')               # 禁用浏览器中的图片加载,以加快页面加载速度
    options.add_experimental_option('excludeSwitches', ['enable-logging'])   # 排除浏览器的日志开关选项,以减少命令行输出

Guess you like

Origin blog.csdn.net/m0_51777056/article/details/130744748