div的內容為:
<div style="background-color: rgb(255, 238, 221);" id="status" class="errors">您輸入的用戶名或密碼有誤。</div>
# coding:utf-8from selenium import webdriverbrowser = webdriver.Firefox()url = 'file:///C:/Users/li/Desktop/hello.html'browser.get(url)alert_inf = "您輸入的用戶名或密碼有誤。"s = browser.find_element_by_xpath("//div[@id='status']")b = s.textprint bif b.encode('utf-8') == alert_inf: print "哈哈哈!ok啦!"else: print "呀,出錯了! 不好玩!"以上這篇在python中獲取div的文本內容并和想定結果進行對比詳解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網。
新聞熱點
疑難解答