Python Selenium入門學習材料整理

2022-08-04 00:36:13 字數 409 閱讀 5998

工業目標:要定位到上面的label。

方法://div[@id="industry"]/parent::div/parent::div/descendant::label #向上找到爺爺輩,再到爺爺輩的子節點中查詢label。

也可以寫成://div[@id="industry"]/../../descendant::label

還可以寫成://div[@id="industry"]/../../div/label

9、xpath 的常見函式

last() 最後乙個節點數

.//*[@id='select2-drop']/ul/li[last()]

參考資料:

1、python+selenium基礎入門及實踐(

2、python爬蟲利器五之selenium的用法(

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...