Selenium入门18 断言
自动化测试需对比实际结果与预期结果,给出测试结论。
1 条件判断 if ...else...
2 assert ...
#coding:utf-8
#断言 from selenium import webdriver dr = webdriver.Firefox()
dr.get("http://www.baidu.com") #if判断
if '百度' in dr.title:
print("test pass")
else:
print("test fail") #assert断言
assert ("百度") in dr.title #断言true,继续执行
dr.find_element_by_id("kw").send_keys("断言")
dr.find_element_by_id("su").click()
print("test pass") #故意写错title
assert '百度000' in dr.title, 'test fail' #断言false,抛出AssertionError异常,输出testfail,中止执行
dr.find_element_by_id("kw").send_keys("断言")
dr.find_element_by_id("su").click()
print("test pass") dr.quit()
Selenium入门18 断言的更多相关文章
- 自动化测试Java一:Selenium入门
From: https://blog.csdn.net/u013258415/article/details/77750214 Selenium入门 欢迎阅读Selenium入门讲义,本讲义将会重点介 ...
- Selenium自动化测试Python一:Selenium入门
Selenium入门 欢迎阅读Selenium入门讲义,本讲义将会重点介绍Selenium的入门知识以及Selenium的前置知识. 自动化测试的基础 在Selenium的课程以前,我们先回顾一下软件 ...
- Selenium 入门到精通系列:六
Selenium 入门到精通系列 PS:Checkbox方法 例子 HTML: <html> <head> <title>测试页面</title> &l ...
- Selenium 入门到精通系列:五
Selenium 入门到精通系列 PS:显式等待.隐式等待.强制等待方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...
- Selenium 入门到精通系列:四
Selenium 入门到精通系列 PS:鼠标右键.鼠标悬停.键盘操作方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...
- Selenium 入门到精通系列:三
Selenium 入门到精通系列 PS:Driver_Element 常用方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2 ...
- Selenium 入门到精通系列:二
Selenium 入门到精通系列 PS:用户登录 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-04-23 16:12 ...
- Selenium 入门到精通系列:一
Selenium 入门到精通系列 PS:控制浏览器窗口大小.前进.后退.刷新 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 20 ...
- Selenium入门6 操作元素,获取元素属性
取元素的text,属性get_attribute,标签名tag_name 操作元素:send_keys输入,click点击,submit提交,clear清除输入 状态判断:is_display,is_ ...
随机推荐
- hdu1028 Ignatius and the Princess III(递归、DP)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- VS 2017与 Docker
https://www.cnblogs.com/rufus-hua/p/6742836.html 参考 1 基于VS2017的Docker Support体检ASP.NET Core站点的Docker ...
- thinkPHP5.0使用form表单提交数据和删除文章,不用TP的提示页面,使用弹出提示信息
form表单提交数据和删除文章时,TP的默认信息提示页面的看起来不是很好看,想要实现弹窗提示怎么做呢? 前端:可以使用前端的一个知识--iframe,iframe元素会创建包含另外一个文档的内联框架: ...
- linux 6 安装 使用 XtraBackup
帮助文档:https://www.cnblogs.com/imweihao/p/7290026.html ---Yum安装 官网地址:https://www.percona.com/doc/perco ...
- java多线程 栅栏CyclicBarrier
CyclicBarrier类介绍A synchronization aid that allows a set of threads to all wait for each other to rea ...
- Neutron命令测试4
jolin@jolin:~$ route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface ...
- Murano Weekly Meeting 2015.10.06
Meeting time: 2015.October.6th 1:00~2:00 Chairperson: Kirill Zaitsev, from Mirantis Meeting summar ...
- 基于log4net自定义异步logging组件
我们在做开发的时候,需要把一些信息记录下来,方便问题排查.数据分析和统计.通常我们使用log4net作为logging的工具,但是大部分时候需要加以封装,以便更加方便的使用,并且不妨碍主业务程序的运行 ...
- 021-动态生成验证码jsp代码模板
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- DEDE列表页和内容页调用顶级栏目ID的方法
dede模板中添加顶级栏目id的方法总结,使用dede顶级栏目id可以实现很多功能.比如,在每个列表页调用不同的栏目图片(同一顶级栏目调用相同的图片),如果我们做N个栏目就意味着要做N个列表页模板,显 ...