时间:2021-08-03 08:58:25 | 栏目:Python代码 | 点击:次
div的内容为:
<div style="background-color: rgb(255, 238, 221);" id="status" class="errors">您输入的用户名或密码有误。</div>
# coding:utf-8
from selenium import webdriver
browser = 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.text
print b
if b.encode('utf-8') == alert_inf:
print "哈哈哈!ok啦!"
else:
print "呀,出错了! 不好玩!"