Python Selenium 學習筆記

2021-08-02 14:42:29 字數 743 閱讀 9416

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("outputbutton").is_displayed() == true

3、判斷元素文字是否相等

driver.find_element_by_id('status').text == (u"驗證碼不正確!")
4、判斷長度是否相等

print len(txtcode.strip())  

if len(txtcode.strip()) == 4:

print u"\n長度相等"

else:

print u"\n長度不相等"

Python Selenium環境搭建

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

Python Selenium錯誤小結

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

Python Selenium環境搭建

linux,mac等系統自帶python,因此這裡主要講windows版本搭建。python3 安裝 其他版本 web based installer 需要聯網安裝,embeddable zip file 壓縮包,嵌入式版本,可嵌入其他應用。第一步 執行python 3.6.x amd64.exe ...