Python selenium案例實戰

2021-10-01 16:43:42 字數 718 閱讀 9131

最近專案有乙個需求:測試人員考勤資料分析結果,歷史的手工測試方式是手動將每一種測試資料依次補加進考勤系統內,這種方式在很大程度上降低了測試的效率,以及資料補加的不準確性,所以,趁此機會,寫了selenium指令碼來替代手工測試。

實現功能如下:迴圈補加考勤資料,分別是簽到裝置、簽到時間,簽退裝置、簽退時間

步驟一:獲取頁面元素資訊

from selenium.webdriver.common.by import by

class subattendpage():

vaguestr=(by.id,'vaguestr')

searchb=(by.id,'searchb')

setreplenishraw=(by.id,'setreplenishraw')

checkall=(by.id,'checkall')

#簽到、簽退裝置

singin_choice=(by.xpath,'//*[@id="form"]/div/div/div[1]/div/div/div/input')

singin=(by.xpath,'//*[@id="form"]/div/div/div[1]/div/d

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