Can anyone explain which all methods are contained by Hard Assertion?

0 votes
May 14, 2019 in Selenium by Monika
76 views

1 answer to this question.

0 votes

Hello @Monika, a Hard Assertion contains following methods:

  • AssertEquals: It is used to compare the actual and expected results. If both the actual and expected results are same, then the assertion pass with no exception and the test case is marked as "passed". If both the actual and expected results are not the same, then the assertion fails with an exception and the test case is marked as "failed". Syntax of an AssertEquals() method is given below:

    • Assert.assertEquals(actual,expected);  
  • AssertNotEquals: It is opposite to the function of AssertEquals() method. AssertNotEquals() is a method used to compare the actual and expected results. If both the actual and expected results are not the same, then the assertion pass with no exception and the test case is marked as "passed". If both the actual and expected results are same, then the assertion fails with an exception and the test case is marked as "failed". Syntax of an AssertNotEquals() method is given below:

    • AssertNotEquals(actual,expected,message);  
  • AssertTrue: Assertion verifies the boolean value returned by a condition. If the boolean value is true, then assertion passes the test case, and if the boolean value is false, then assertion aborts the test case by an exception. Syntax of AssertTrue() method is given below:

    • Assert.AssertTrue(condition);  
  • AssertFalse: This verifies the boolean value returned by a condition. If the boolean value is false, then assertion passes the test case, and if the boolean value is true, then assertion aborts the test case by an exception. Syntax of AssertFalse() method is given below:

    • Assert.AssertFalse(condition);
  • AssertNull: It is a method that verifies whether the object is null or not. If an object is null, then assertion passes the test case, and the test case is marked as "passed", and if an object is not null, then assertion aborts the test case and the test case is marked as "failed". Syntax of AssertNull() method is given below:

    • Assert.assertNull(object);  
  • AssertNotNull: AssertNotNull() is a method that verifies whether the object is null or not. If an object is not null, then assertion passes the test case and test case is marked as "passed", and if an object is null, then assertion aborts the test case and test case is marked as "failed". Syntax of AssertNotNull() method is given below:

    • Assert.assertNotNull(object);  
answered May 14, 2019 by Pratibha
• 3,690 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

What all test methods are provided by Assert class in JUnit?

Hello Apeksha, JUnit provides static methods in the ...READ MORE

answered Oct 17, 2019 in Selenium by Abha
• 27,930 points
472 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,480 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,490 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,572 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,809 views
0 votes
2 answers
0 votes
1 answer

Can anyone explain how an AJAX call can be handled in Selenium webdriver?

Hello Megha, to demonstrate how AJAX calls are ...READ MORE

answered May 8, 2019 in Selenium by Pratibha
• 3,690 points
351 views