自动化测试需对比实际结果与预期结果,给出测试结论。

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 断言的更多相关文章

  1. 自动化测试Java一:Selenium入门

    From: https://blog.csdn.net/u013258415/article/details/77750214 Selenium入门 欢迎阅读Selenium入门讲义,本讲义将会重点介 ...

  2. Selenium自动化测试Python一:Selenium入门

    Selenium入门 欢迎阅读Selenium入门讲义,本讲义将会重点介绍Selenium的入门知识以及Selenium的前置知识. 自动化测试的基础 在Selenium的课程以前,我们先回顾一下软件 ...

  3. Selenium 入门到精通系列:六

    Selenium 入门到精通系列 PS:Checkbox方法 例子 HTML: <html> <head> <title>测试页面</title> &l ...

  4. Selenium 入门到精通系列:五

    Selenium 入门到精通系列 PS:显式等待.隐式等待.强制等待方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...

  5. Selenium 入门到精通系列:四

    Selenium 入门到精通系列 PS:鼠标右键.鼠标悬停.键盘操作方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...

  6. Selenium 入门到精通系列:三

    Selenium 入门到精通系列 PS:Driver_Element 常用方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2 ...

  7. Selenium 入门到精通系列:二

    Selenium 入门到精通系列 PS:用户登录 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-04-23 16:12 ...

  8. Selenium 入门到精通系列:一

    Selenium 入门到精通系列 PS:控制浏览器窗口大小.前进.后退.刷新 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 20 ...

  9. Selenium入门6 操作元素,获取元素属性

    取元素的text,属性get_attribute,标签名tag_name 操作元素:send_keys输入,click点击,submit提交,clear清除输入 状态判断:is_display,is_ ...

随机推荐

  1. Flask&&人工智能AI -- 8 HTML5+ 初识,HBuilder,夜神模拟器,Webview

    昨日内容回顾 1.增删改查: 增: db.collections.insert({a:1}) // 官方不推荐了 db.collections.insertMany([{a:1},{b:1}]) in ...

  2. datatables通过ajax调用渲染数据,怎么根据数据给td添加class

    html: <table id="table8" cellpadding="0" cellspacing="0" border=&qu ...

  3. hdu3746 KMP-next数组的应用

    Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  4. centos7初始优化

    第1章 优化 1.1 修改yum源 epel源 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Cen ...

  5. java/Android String.split 字符串分割

    特殊符号分割时需加[].如下图

  6. my.宠物价格_资料

    1.梦幻西游手游宠物估价五大实用技巧_72G梦幻西游手游专区.html http://www.72g.com/game/mhxysy/88470.html 梦幻西游手游宠物估价五大实用技巧 作者:升仙 ...

  7. 树莓派安装Raspbian系统以及相关配置(通过Windows)

    1.准备 树莓派3B+(E14) 一张内存卡 (至少16G) 一个读卡器 普通电脑显示器,键盘,鼠标 2.操作系统烧制(下面的操作都是在Windows中操作,通过读开启读取内存卡) Raspbian系 ...

  8. Unable to instantiate receiver xxx.receiver.NetworkReceiver异常

    Unable to instantiate xxxreceiver.NetworkReceiver: 这个异常是之前版本有NetworkReceiver(监听网络变化的),新的版本删除了Network ...

  9. Ordering Tasks UVA - 10305(拓扑排序)

    在一个有向图中,对所有的节点进行排序,要求没有一个节点指向它前面的节点. 先统计所有节点的入度,对于入度为0的节点就可以分离出来,然后把这个节点指向的节点的入度减一. 一直做改操作,直到所有的节点都被 ...

  10. Django重新整理4---ModelForm-set(批量处理数据)

    1. #引用modelformset from django.forms.models import modelformset_factory #必须继承forms.ModelForm! class ...