Selenium predicts the world through Assert and seleniumassert

Source: Internet
Author: User

Selenium predicts the world through Assert and seleniumassert
I. Overview

We all know that each test case has an execution result, so we need to determine whether the execution result is consistent with the expected result. When selenium executes the test case

How can we determine this? Let's take a look at the predictive cheats of selenium webdriver.

2. Compile an Assertion class that can predict the world
 

 

1 package com. daanhealth. tnb. util; 2 3 import java. util. arrayList; 4 import java. util. list; 5 6 import org. testng. assert; 7 8 9 public class Assertion {10 11 public static Log log = new Log (Assertion. class); 12 13 public static boolean flag = true; 14 15 public static List <Error> errors = new ArrayList <Error> (); 16 17 public static void begin () {18 flag = true; 19} 20 21 public static void end () {22 Assert. asser TTrue (flag); 23} 24 25 public static void verifyEquals (Object actual, Object expected) {26 try {27 Assert. assertEquals (actual, expected); 28} catch (Error e) {29 errors. add (e); 30 flag = false; 31} 32} 33 34 public static void verifyEquals (Object actual, Object expected, String message) {35 try {36 Assert. assertEquals (actual, expected, message); 37 log.info ("method Verification Successful! "); 38} catch (Error e) {39 errors. add (e); 40 flag = false; 41 log.info (" method Verification Failed! "); 42} 43} 44 45}View Code

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.