【Python】selenium模組_安裝配置
阿新 • • 發佈:2022-04-07
簡介
selenium 是一個用於Web應用程式測試的工具。
Selenium測試直接執行在瀏覽器中,就像真正的使用者在操作一樣。
支援的瀏覽器包括IE、Mozilla Firefox、Mozilla Suite等。
這個工具的主要功能包括:
測試與瀏覽器的相容性——測試你的應用程式看是否能夠很好得工作在不同瀏覽器和作業系統之上。
測試系統功能——建立衰退測試檢驗軟體功能和使用者需求。
支援自動錄製動作和自動生成。Net、Java、Perl等不同語言的測試指令碼。
Selenium 是ThoughtWorks專門為Web應用程式編寫的一個驗收測試工具
安裝
pip install selenuim
引用
from selenium import webdriver
配置
把driver放在python的Scripts路徑下,同時把script路徑加入環境變數
谷歌驅動【chromedriver】下載地址:http://chromedriver.storage.googleapis.com/index.html
火狐歷史版本下載地址: http://ftp.mozilla.org/pub/firefox/releases/
火狐驅動【geckodriver】下載地址: https://github.com/mozilla/geckodriver/releases
IE瀏覽器驅動【IEdriver】下載地址: http://dl.pconline.com.cn/download/771640-1.html http://www.nuget.org/packages/Selenium.WebDriver.IEDriver/
拓展
參考連結: https://www.cnblogs.com/hellosecretgarden/p/9206648.html
問題一:元素不可互動
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
可能原因,加延遲等待幾秒在查詢元素
time.sleep(5)
問題二: