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)】


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM