div的內(nèi)容為:
<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("http://div[@id='status']")b = s.textprint bif b.encode('utf-8') == alert_inf: print "哈哈哈!ok啦!"else: print "呀,出錯(cuò)了! 不好玩!"以上這篇在python中獲取div的文本內(nèi)容并和想定結(jié)果進(jìn)行對(duì)比詳解就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持武林站長(zhǎng)站。
新聞熱點(diǎn)
疑難解答
圖片精選