【Python】unittest-5
#练习9:
import unittest
from selenium import webdriver
import time class GloryRoad(unittest.TestCase):
def setUp(self):
# 启动Firefox浏览器
self.driver = webdriver.Chrome(executable_path = "c:\\chromedriver") def testSoGou(self):
# 访问搜狗首页
self.driver.get("http://sogou.com")
# 清空搜索输入框默认内容
self.driver.find_element_by_id("query").clear()
# 在搜索输入框中输入“光荣之路自动化测试”
self.driver.find_element_by_id("query").send_keys(u"WebDriver实战宝典")
# 单击“搜索”按钮
self.driver.find_element_by_id("stb").click()
# 等待3秒
time.sleep(3)
assert u"吴老师" in self.driver.page_source, u"页面中不存在要寻找的关键字!".encode("gbk") def testBing(self):
# 访问搜狗首页
self.driver.get("http://cn.bing.com")
# 清空搜索输入框默认内容
self.driver.find_element_by_id("sb_form_q").clear()
# 在搜索输入框中输入“光荣之路自动化测试”
self.driver.find_element_by_id("sb_form_q").send_keys(u"WebDriver实战宝典")
# 单击“搜索”按钮
self.driver.find_element_by_id("sb_form_go").click()
# 等待3秒
time.sleep(3)
assert u"王老师" in self.driver.page_source, u"页面中不存在要寻找的关键字!".encode("gbk") def tearDown(self):
# 退出浏览器
self.driver.quit() if __name__ == '__main__':
unittest.main()
【Python】unittest-5的更多相关文章
- 【python】unittest中常用的assert语句
下面是unittest模块的常用方法: assertEqual(a, b) a == b assertNotEqual(a, b) a != b assertTrue(x) b ...
- 【Python②】python之首秀
第一个python程序 再次说明:后面所有代码均为Python 3.3.2版本(运行环境:Windows7)编写. 安装配置好python后,我们先来写第一个python程序.打开IDLE (P ...
- 【python】多进程锁multiprocess.Lock
[python]多进程锁multiprocess.Lock 2013-09-13 13:48 11613人阅读 评论(2) 收藏 举报 分类: Python(38) 同步的方法基本与多线程相同. ...
- 【python】SQLAlchemy
来源:廖雪峰 对比:[python]在python中调用mysql 注意连接数据库方式和数据操作方式! 今天发现了个处理数据库的好东西:SQLAlchemy 一般python处理mysql之类的数据库 ...
- 【python】getopt使用
来源:http://blog.chinaunix.net/uid-21566578-id-438233.html 注意对比:[python]argparse模块 作者:limodou版权所有limod ...
- 【Python】如何安装easy_install?
[Python]如何安装easy_install? http://jingyan.baidu.com/article/b907e627e78fe146e7891c25.html easy_instal ...
- 【Python】 零碎知识积累 II
[Python] 零碎知识积累 II ■ 函数的参数默认值在函数定义时确定并保存在内存中,调用函数时不会在内存中新开辟一块空间然后用参数默认值重新赋值,而是单纯地引用这个参数原来的地址.这就带来了一个 ...
- 【Python】-NO.97.Note.2.Python -【Python 基本数据类型】
1.0.0 Summary Tittle:[Python]-NO.97.Note.2.Python -[Python 基本数据类型] Style:Python Series:Python Since: ...
- 【Python】-NO.99.Note.4.Python -【Python3 条件语句 循环语句】
1.0.0 Summary Tittle:[Python]-NO.99.Note.4.Python -[Python3 条件语句 循环语句] Style:Python Series:Python Si ...
- 【Python】-NO.98.Note.3.Python -【Python3 解释器、运算符】
1.0.0 Summary Tittle:[Python]-NO.98.Note.3.Python -[Python3 解释器] Style:Python Series:Python Since:20 ...
随机推荐
- const typedef 和指针的问题(这里必须初始化的才初始化了,不必须的则没有初始化)
这里很容易搞混: tyepdef double dou;//这里是dou是double的别名 #include<iostream> using namespace std; int mai ...
- hash、hashchange事件
1.hash即URL中"#"字符后面的部分. ①使用浏览器访问网页时,如果网页URL中带有hash,页面就会定位到id(或name)与hash值一样的元素的位置: ②hash还有另 ...
- python-day74--知识总体总结
1. 课程介绍 - 数据类型 - 函数 - 面向对象三大特性:继承,封装,多态 - socket:本质传输字节:所有网络通信都基于socket ...
- GitHub学习四-查看版本库信息
首先,只有在本地init以及关联到远程版本库的本地版本库,才能查看版本库信息 1.查看版本库名字 如果忘了名字,直接运行git remote 2.git remote show <name> ...
- ORA-04068 / ORA-04065 / ORA-06508 详细说明
关于在运行ORACLE 包发生ORA-04068 / ORA-04065 / ORA-06508 代码异常的原因只有一个,那就是包含了全局变量/常量的包,在会话保留期间被执行了编译. 对于此类错误,我 ...
- 关于cf[转]
还不怎么熟悉cf呢.. 你应当知道的关于Codeforces的事情 Codeforces简称: cf(所以谈论cf的时候经常被误会成TX的那款游戏).网址: codeforces.com 这是一个俄国 ...
- H5新特性实现对class的增删改
直接撸代码 全靠死记硬背 没什么技术点 HTML部分 <!DOCTYPE html> <html lang="en"> <head> <m ...
- js--阻止冒泡,捕获,默认行为
防止冒泡和捕获 w3c的方法是e.stopPropagation(),IE则是使用e.cancelBubble = true· var el = window.document.getElementB ...
- css3 居中(推荐弹性盒模型方式)
参考 http://www.zhihu.com/question/20774514 http://caibaojian.com/demo/flexbox/align-items.html 例子:ht ...
- Tomcat错误:getOutputStream() has already been called for this response
使用weblogic部署时,没有报错.客户现场使用tomcat后报错. 在tomcat下jsp中出现此错误一般都是在jsp中使用了输出流(如输出图片验证码,文件下载等),没有妥善处理好的原因.具体的原 ...