Selenium 找了很久,没有发现有verify的方法,可是,有个时候要的是确认,而不是直接断言,
当然要在运行结束后能够得到确认的结果,于是写了下面的代码,给大家分享。
 
 
import java.util.ArrayList;
import java.util.List;
import org.testng.Assert;

public class Assertion {
    public static boolean flag = true;
    public static List<Error> errors = new ArrayList<Error>();

    public void verifyBegin() {
        flag = true;                                                                    // flag默认为 true
      //  errors.clear();                                                                // 如果要@dataProvider每次都断言
    }
    public void verifyEnd() {
        Assert.assertTrue(flag, errors.toString());                    //如果flag为false、则输出放入堆栈中的 error
    }

public void verifyEquals(Object actual, Object expected) {
        try {
            Assert.assertEquals(actual, expected);                   // 断言 assert 
        }
        catch (Error e) {
            errors.add(e);                                                           //如果断言为失败,将error写入堆栈
            flag = false;                                                              // flag 改为 false
        }
    }

public void verifyEquals(Object actual, Object expected, String message) {
        try {
            Assert.assertEquals(actual, expected, message);
        }
        catch (Error e) {
            errors.add(e);
            flag = false;
        }
    }

public void verifyTure(Boolean bl, String message) {
        try {
            Assert.assertTrue(bl, message);
        }
        catch (Error e) {
            errors.add(e);
            flag = false;
        }
    }

}

Selenium自动化测试 Verify的更多相关文章

  1. JavaScript(Node.js)+ Selenium自动化测试

    Selenium is a browser automation library. Most often used for testing web-applications, Selenium may ...

  2. Selenium自动化测试框架介绍

    Selenium自动化测试框架介绍 1.测试架构作用 a.可维护性 b.提高编写脚本效率 c.提高脚本的可读性 2.框架的几大要素: Driver管理,脚本,数据,元素对象,LOG,报告,运行机制,失 ...

  3. Eclipse+Selenium自动化测试脚本设计V1.0

    Eclipse+Selenium自动化测试脚本设计V1.0 http://www.docin.com/p-803032251.html

  4. Selenium自动化测试实践 公开班(广州)

    Selenium自动化测试实践 公开班(广州) http://gdtesting.com/product.php?id=115

  5. Selenium自动化测试项目案例实践公开课

    Selenium自动化测试项目案例实践公开课: http://gdtesting.cn/news.php?id=55

  6. 圆满完成Selenium自动化测试周末班培训课程!

    圆满完成Selenium自动化测试周末班培训课程! http://automationqa.com/forum.php?mod=viewthread&tid=2704&fromuid= ...

  7. selenium自动化测试(1):环境搭建

    Selenium是一款优秀的WEB自动化测试工具,它功能强大,易于使用,支持多种平台.多种浏览器和多种开发语言.这里介绍使用python+selenium进行自动化测试的一些基础知识. 在Window ...

  8. Python网络数据采集7-单元测试与Selenium自动化测试

    Python网络数据采集7-单元测试与Selenium自动化测试 单元测试 Python中使用内置库unittest可完成单元测试.只要继承unittest.TestCase类,就可以实现下面的功能. ...

  9. selenium自动化测试学习(一)

    在学习selenium自动化测试前,我们需要先了解一点自动化测试的相关知识. (一)什么是自动化测试 (二)为什么要做自动化测试 (三)自动化测试优缺点 (1)什么是自动化测试 自动化测试是把以人为驱 ...

随机推荐

  1. Golang Go Go Go part1:安装及运行

    golang 知识图谱 https://www.processon.com/view/link/5a9ba4c8e4b0a9d22eb3bdf0 一.安装 最新版本安装包地址:https://gola ...

  2. Tensorboard可视化(关于TensorFlow不同版本引起的错误)

    # -*- coding: utf-8 -*-"""Created on Sun Nov 5 15:28:50 2017 @author: Administrator&q ...

  3. 【转载】看StackOverflow如何用25台服务器撑起5.6亿的月PV

    问答社区网络 StackExchange 由 100 多个网站构成,其中包括了 Alexa 排名第 54 的 StackOverflow.StackExchang 有 400 万用户,每月 5.6 亿 ...

  4. 【RL-TCPnet网络教程】第29章 NTP网络时间协议基础知识

    第29章      NTP网络时间协议基础知识 本章节为大家讲解NTP (Network Time Protocol,网络时间协议)和SNTP(简单网络时间协议,Simple Network Time ...

  5. 分门别类总结Java中的各种锁,让你彻底记住

    概念 公平锁/非公平锁 公平锁是指多个线程按照申请锁的顺序来获取锁. 非公平锁是指多个线程获取锁的顺序并不是按照申请锁的顺序,有可能后申请的线程比先申请的线程优先获取锁.有可能,会造成优先级反转或者饥 ...

  6. [Swift]LeetCode27. 移除元素 | Remove Element

    Given an array nums and a value val, remove all instances of that value in-place and return the new ...

  7. [SQL]LeetCode183. 从不订购的客户 | Customers Who Never Order

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  8. [Swift]LeetCode401. 二进制手表 | Binary Watch

    A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom ...

  9. [Swift]LeetCode957. N天后的牢房 | Prison Cells After N Days

    There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the ...

  10. PHP算法之选择排序

    //选择排序 $array = [10,203,30,2,4,43]; //第一次从下标为0的开始下标为0的这个数与后面的n-1个进行比较:找出最小或者最大的放在下标为0的这个位置; //第二次从下标 ...