As described inward my previous post, assertEquals assertion is useful to compare ii string, boolean, byte[], char, double, float, int, etc.. in addition to based on assertion result, Your evidence method volition overstep or fail. This overstep or neglect indication volition helps y'all inward your testing process. So this is the rattling skilful business office inward selenium WebDriver which helps us to abide by in addition to log issue. Please banknote 1 matter again is - Use hard assertions inward selenium webdriver alone when y'all wants to skip remaining evidence execution on assertion fail. If y'all wants to cash inward one's chips along execution on assertion failure, y'all tin role TestNg soft assertions. We volition hash out nearly it inward my upcoming post.
You tin VIEW SELENIUM IDE ASSERTION EXAMPLES for your reference.
Assert.assertNotEquals(actual, expected, message) assertion
Other 1 assertion inward selenium WebDriver is assertNotEquals assertion. It's business office is contrary to assertEquals assertion. Means if both sides values volition non agree in addition to hence this assertion volition overstep else it volition fail. Here y'all tin write your ain message for failure condition. Simplest instance of Assert.assertNotEquals inward selenium webdriver is equally bellow.
Replace bellow given evidence methods (assertion_method_1() in addition to assertion_method_2()) amongst instance given inward my PREVIOUS POST in addition to and hence travel it using testng.xml file.
//Assertion Method @Test world void assertion_method_1() { Actualtext = driver.findElement(By.xpath("//h2/span")).getText(); Assert.assertNotEquals(Actualtext, "Tuesday, 28 Jan 2014", "Expected in addition to actual agree inward assertion_method_1"); System.out.print("\n assertion_method_1() -> Part executed"); } //Assertion Method @Test world void assertion_method_2() { Assert.assertNotEquals(Actualtext, "Tuesday, 29 Jan 2014", "Expected in addition to actual agree inward assertion_method_2"); System.out.print("\n assertion_method_2() -> Part executed"); }
You evidence execution outcome volition looks similar bellow..
Here, evidence method assertion_method_1() volition neglect because actual string text in addition to expected string text volition match. Assertion message volition survive printed inward evidence outcome study equally marked amongst greenish color inward in a higher house image.
http://www.software-testing-tutorials-automation.com/