Python selenium模組報錯解決

2021-09-30 17:55:50 字數 882 閱讀 5932

在使用selenium的webdriver示例化firefox和chrome物件時,發現如下報錯。

如上圖,例項firefox物件,報錯:selenium.common.exceptions.webdriverexception: message: invalid argument: can't kill an exited process

如上圖,例項化chrome物件,報錯:selenium.common.exceptions.webdriverexception: message: unknown error: chrome failed to start: exited abnormally

檢查對應的驅動,是已經放到path變數路徑的。

如上圖,geckodriver,chromedriver已經放置到/usr/local/bin目錄下,且有+x許可權。

最開始懷疑是和目前已經開啟的火狐和chrome瀏覽器衝突,於是關閉本機對應的火狐和chrome瀏覽器,執行上述**,報錯依舊。

後面切換到用普通使用者執行,發現可以正常執行。

Python Selenium環境搭建

安裝python 設定 python 的環境變數 安裝目錄 安裝目錄 scripts 使用 pip安裝 selenium pip install selenium 安裝完python pip工具,在安裝目錄的 scripts 目錄下。在 dos下直接執行 pip install selenium 即...

Python Selenium 學習筆記

1 判斷元素是否存在 try driver.find element.xx a true except a false if a true print 元素存在 elif a false print 元素不存在 2 判斷元素是否顯示 driver.find element by id outputb...

Python Selenium錯誤小結

因為要使用web應用,所以開始用起了,selenium包,安裝倒是挺容易的,但就是出了很多bug。filenotfounderror winerror 2 系統找不到指定的檔案。通過錯誤反饋發現是要把該軟體加到路徑裡面,但是,設定了系統環境變數後發現還是不行,最後,使用了乙個非常原始的方法 brow...