在python中获取div的文本内容并和想定结果进行对比详解
作者:请叫我怪兽_谢谢 时间:2021-09-05 07:29:37
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 "呀,出错了! 不好玩!"
来源:https://blog.csdn.net/MiaoDaLengShui/article/details/51683387
标签:python,div,文本
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
详解PHP的引用计数
2023-11-14 18:00:34
浅析Python中的赋值和深浅拷贝
2021-09-10 14:30:14
![](https://img.aspxhome.com/file/2023/9/78549_0s.png)
Python实现检测服务器是否可以ping通的2种方法
2023-06-07 20:18:14
![](https://img.aspxhome.com/file/2023/0/88920_0s.jpg)
Django框架实现的普通登录案例【使用POST方法】
2021-10-12 18:05:10
![](https://img.aspxhome.com/file/2023/5/88895_0s.png)
基于php常用函数总结(数组,字符串,时间,文件操作)
2023-11-24 00:23:46
Python中内建函数的简单用法说明
2021-09-01 08:19:58
php源码的安装方法和实例
2023-07-06 03:31:37
php购物车实现方法
2023-11-16 22:54:51
PLSQLDeveloper登录远程连接Oracle的操作
2023-07-23 03:34:22
![](https://img.aspxhome.com/file/2023/1/64081_0s.png)
asp Driver和Provider两种连接字符串连接Access时的区别
2011-03-09 11:19:00
一个asp版的xheditor上传图片服务器端文件
2009-12-21 14:18:00
![](https://img.aspxhome.com/file/UploadPic/20101/11/200982514518-20s.jpg)
常用Oracle分析函数大全
2023-07-03 08:16:14
![](https://img.aspxhome.com/file/2023/0/63710_0s.jpg)
用户体验量化方法研究(二)
2010-02-08 12:46:00
matplotlib图例legend语法及设置的方法
2023-01-07 04:23:37
![](https://img.aspxhome.com/file/2023/6/78516_0s.png)
番茄的js表单验证类
2008-01-07 13:53:00
详解Python中的相对导入和绝对导入
2023-02-05 01:10:36
CSS 的优先规则
2009-01-08 12:40:00
深入理解Python分布式爬虫原理
2023-02-06 14:33:30
![](https://img.aspxhome.com/file/2023/8/66458_0s.jpg)
jQuery 1.4新特性及其变化(上)
2010-01-18 16:33:00
pycharm配置python 设置pip安装源为豆瓣源
2022-07-16 12:09:43
![](https://img.aspxhome.com/file/2023/0/86250_0s.png)