无法将参数传递到selenium中的chrome驱动程序

2024-04-26 18:34:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用selenium测试我的chrome扩展,最近发现Travis CI报告了一个失败状态。在

travis-ci screenshot

我重现了这个问题,意识到chrome甚至没有加载我的扩展。在

下面是一个简短的例子:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

opt=Options()
opt.add_argument('load-extension=/path/to/src')
opt.add_argument('--user-agent=foobar')

b=webdriver.Chrome('driver/chromedriver',chrome_options=opt)
print(b.execute_script('return navigator.userAgent'))

chrome启动时没有加载扩展名,用户代理字符串仍然是默认字符串(Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36)。在

我使用的chrome驱动程序是v2.33google-chrome-stable (62.0.3202.75-1)。操作系统是ubuntu14.04lts(这个bug在Windows中是不可复制的)。在

我想知道硒是最近的一个代码更新。在

有没有解决这个bug的方法?在

(对不起我的英语不好)


Tags: 字符串fromimporttravisciaddseleniumchrome
1条回答
网友
1楼 · 发布于 2024-04-26 18:34:53

比较两个构建输出,selenium的版本从3.6.0更改为3.7.0。在

enter image description here

将硒降级到selenium==3.6.0将解决这个问题。在

相关问题 更多 >