天天看點

python+selenium 者常見錯誤

1.浏覽器版本于driver與相容,需要重新下載下傳相容浏覽器版本的驅動

call function result missing 'value
           
cannot get automation extension
           

解決方案:

Chrome 驅動位址

參考版本:

chrome:67.0.3396.62(正式版本)

driver:2.37.0

注:64位計算機相容32位

更多關于driver問題: chrome版本和chromedriver.exe

2.selenium 文法錯誤: Message: no such session

Traceback (most recent call last): File "E:/Python_selenium/PycharmProjects/data/run.py", line 22, in print(driver.title)

  File "E:\Python_selenium\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 222, in title

    resp = self.execute(Command.GET_TITLE)

  File "E:\Python_selenium\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute

    self.error_handler.check_response(response)

  File "E:\Python_selenium\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response

    raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: no such session
           

3.

clear()

無效的元素狀态:元素必須是使用者可編輯的,才能清除它。

invalid element state: Element must be user-editable in order to clear it.

首先需要確定這個元素能輸入内容,如果可以send_keys(),卻不能clear(),那麼試試先對元素click(),讓焦點在元素上再clear()

4.彈出Edit configuration 解決方案

在GitHub上下載下傳了一個項目,導入後每執行一個子產品都會彈出,如下圖:(PS:因為問題發生時忘記截圖,現在網上找了一個圖)

python+selenium 者常見錯誤

原因是 這個工程沒有配置python解釋器,具體設定方法如下:

1.打開File下的settings

python+selenium 者常見錯誤

2.選擇相應的python解釋器後,點選Apply(必要步驟),點選OK,設定完成,此工程檔案可以正常執行了

python+selenium 者常見錯誤