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

Robot+Selenium出现browser_profile参数报错,降级版本仍未解决

问题原因及解决方案

核心原因

你遇到的问题根源不是Selenium容器版本,而是自定义测试容器里的依赖版本不匹配:

  • 虽然你将Selenium容器降级到了4.9.1,但自定义容器中仅指定了robotframework==6.0.2和robotframework-seleniumlibrary==6.0.0,未锁定Selenium Python库版本。pip会自动安装满足selenium >=4.1.0依赖的最新版本(也就是4.10+),而这个版本的WebDriver.__init__已经移除了browser_profile参数。
  • robotframework-seleniumlibrary 6.0.0内部仍在使用browser_profile参数初始化WebDriver,和新版Selenium库API冲突,导致报错。

两种可行解决方案

方案1:锁定Selenium Python库版本,与容器版本匹配

在自定义容器的依赖清单(如requirements.txt)中明确指定Selenium版本为4.9.1,确保客户端和服务端版本一致:

robotframework==6.0.2
robotframework-seleniumlibrary==6.0.0
selenium==4.9.1

重新构建自定义容器后,测试脚本就能正常使用browser_profile参数。

方案2:升级库版本适配Selenium 4.10+新API

如果想使用Selenium 4.10+的特性,需要同步升级robotframework-seleniumlibrary到7.0.0及以上版本(这些版本已适配Selenium 4.10+的API,移除了browser_profile参数的使用),同时升级Selenium容器版本:

  1. 修改依赖清单:
robotframework==6.0.2
robotframework-seleniumlibrary==7.0.0
selenium==4.10.0
  1. 启动对应版本的Selenium容器:
docker run -d --rm -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 2g --name webdriver seleniarm/standalone-chromium:4.10.0
  1. 调整Robot脚本中的浏览器profile配置方式,改用options参数(Selenium 4.10+的标准方式):
${profile_options}=    Create Dictionary    user-data-dir=/path/to/your/profile
Create WebDriver    Chrome    options=${profile_options}    remote_url=http://webdriver:4444/wd/hub

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 08:27:35