Jenkins调用selenium找不到webdriver:selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

jenkins集成web_UI自动化脚本,发送的html报告中显示:   

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

如下图:

使用Chrome浏览器时,经常会遇到以下报错:浏览器没有调用起来

通常由两种问题引起的:

1.ChromeDriver.exe驱动有问题(包括版本,路径等等)

2.Chrome.exe本身有问题。

网上搜索的解决方案:三个

1.指定chromedriver.exe驱动绝对路径

driver = webdriver.Chrome(r'd:\xxx\chromedriver.exe')

2.添加chrome.exe到系统path环境变量

3.在代码中指定chrome.exe绝对路径。设置binary_location属性

option = webdriver.ChromeOptions()

option.binary_location=r'C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe

driver = webdriver.Chrome()

driver.get('https://www.baidu.com')


以上方案均未解决我的问题,最终解决方案如下:

   原因是:安装的chrome浏览器是在userApp下面,jenkins运行找不到

   解决方法如下两种:

  1.重新安装chrome放在C:\Program Files (x86)下面

  C:\Program Files (x86)\Google\Chrome\Application

  2.【从user下面拷贝整个google文件夹到:C:\Program Files (x86)】

猜你喜欢

转载自www.cnblogs.com/caixinxiong/p/12616720.html