You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu系统下使用Selenium 4.11.2无法启动Edge浏览器求助

解决Selenium启动Edge浏览器却打开Chrome的问题
  • 检查系统环境变量,确认未将ChromeDriver路径设为全局默认,避免Selenium优先读取错误的驱动路径。
  • 显式指定Edge浏览器的二进制路径,强制Selenium调用Edge:
    from selenium import webdriver
    from selenium.webdriver.edge.options import Options
    from os.path import join, expanduser
    
    HOME = expanduser("~")
    edgedriver = join(HOME, "webdrivers", "msedgedriver")
    edge_options = Options()
    # 根据系统替换为Edge实际安装路径
    # Windows示例:edge_options.binary_location = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
    # macOS示例:edge_options.binary_location = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
    edge_options.binary_location = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
    service = webdriver.EdgeService(executable_path=edgedriver)
    driver = webdriver.Edge(service=service, options=edge_options)
    
    driver.get("https://google.com")
    
  • 重启终端或IDE,清除可能残留的Selenium配置缓存或旧驱动进程。
  • Linux/macOS系统下,确保msedgedriver有执行权限,执行命令:chmod +x /path/to/msedgedriver

内容的提问来源于stack exchange,提问作者PKlumpp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 05:52:03