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