selenium中webdriver常用的ChromeOptions参数

官网链接:Browser Options | Selenium

使用示例:

python 复制代码
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

# 创建选项对象
options = Options()

# 设置浏览器启动时的窗口大小
options.add_argument("--window-size=1920,1080")

# 启动浏览器时不显示图形界面
options.add_argument("--headless")

# 创建Chrome WebDriver时传入选项对象
driver = webdriver.Chrome(options=options)

# 访问网页
driver.get("https://www.example.com")

# 在这里进行其他操作...

# 关闭浏览器
driver.quit()

常用参数:

  1. add_argument(argument):添加命令行参数。
  2. add_experimental_option(name, value):添加实验性质的选项。
  3. binary_location:设置Chrome浏览器可执行文件的路径。
  4. debugger_address:指定远程调试地址。
  5. headless:设置浏览器是否以无头模式(不显示界面)运行。
  6. window_size:设置浏览器窗口的大小。
  7. user_data_dir:指定用户数据目录,可以用于设置用户配置、缓存等信息。
  8. profile_directory:指定用户配置文件目录。
  9. disable_extensions:禁用扩展程序。
  10. disable_gpu:禁用GPU加速。
  11. no_sandbox:禁用沙盒模式。
  12. disable_notifications:禁用通知。
  13. disable_infobars:禁用信息栏。
  14. disable_web_security:禁用Web安全性。
  15. incognito:启动隐身模式。
  16. ignore_certificate_errors:忽略SSL证书错误。
  17. disable_dev_shm_usage:禁用/dev/shm使用。
  18. disable_setuid_sandbox:禁用setuid沙盒。
  19. disable_background_networking:禁用后台网络。
  20. disable_client_side_phishing_detection:禁用客户端端钓鱼检测。
  21. disable_component_extensions_with_background_pages:禁用后台页面的组件扩展例如密码管理、自动填表、翻译等。
  22. disable_default_apps:禁用默认应用。
  23. disable_file_system:禁用文件系统API。
  24. disable_fullscreen:禁用全屏模式。
  25. disable_sync:禁用同步功能。
  26. disable_tab_for_desktop_share:禁用桌面共享选项卡。
  27. disable-features=Translate:禁用 Chrome 翻译,包括手动选项和检测到不同语言的页面时弹出的提示。
  28. disable-features=GlobalMediaControls:隐藏可打开用于控制媒体会话的对话框的工具栏按钮。
  29. disable-external-intent-requests:禁止在外部应用程序中打开链接。
  30. disable-notifications:禁用 Web 通知和推送 API
  31. disable-sync:禁用同步到 Google 帐户
  32. hide_scrollbars:隐藏滚动条。
  33. mute_audio:静音浏览器。
  34. no-first-run:跳过首次运行向导
  35. aggressive-cache-discard:缓存丢弃
  36. allow-running-insecure-content:允许运行不安全内容
  37. deny-permission-prompts:通过自动拒绝来抑制所有权限提示。
相关推荐
杨杨杨大侠4 小时前
Jev、Kev、Laya:决策模型怎么选,什么时候需要微调?
人工智能·python·agent
LOVE️YOU5 小时前
Python 在定义函数时,究竟定义的是什么?
python
段一凡-华北理工大学5 小时前
大模型应用开发 100 天:Python + LLM 从入门到精通 day26~Prompt 调试与优化——A/B 测试与效果评估
windows·python·大模型·prompt·智能体·提示词工程·高炉智能化
Minecraft红客5 小时前
以撒的结合
python·游戏·电脑·娱乐
Circ.5 小时前
Python 调试 Litellm 本地大模型接口:模型列表与对话接口实操踩坑记录
开发语言·python
风早爽太6 小时前
用 ‌Render‌ 快速部署网站和常见问题解决
python·fastapi
李航19837 小时前
给自己的图形引擎,配上了AI渲染,做设计真是太方便了
人工智能·python·计算机视觉·ai·ai编程
L@ncor7 小时前
第六章 框架开发实践 · 学习笔记(AutoGen / AgentScope / CAMEL / LangGraph)
python·框架·autogen·langgraph·agentscope
Zhou1411367 小时前
SpringSecurity_02_授权与高级功能
开发语言·python
摇滚侠9 小时前
《On Java 中文版 基础卷》阅读笔记 对象无处不在 03
java·笔记·python