Assertions

 1. Explain assertions with their arguments

  • assertTrue(boolean condition,String message)
  • assertTrue(boolean condition)
  • assertFalse(boolean condition,String message)
  • assertFalse(boolean condition)
  • assertEquals(String actual,String expected,String message)
  • assertNotNull(Object object,String message)
  • assertNull(Object object,String message)
  • assertSame(Object actual,Object expected,String message)
  • assertNotSame(Object actual,Object expected,String message)

2.What are the assertions in selenium?

Assertions are like checkpoints to verify whether system is behaving as expected.There are two types of assertion in selenium.

  1. soft Asserts 
  2. Hard asserts

Soft Assert : Verify certain test conditions are true or false. If it is passed or fail it move to the next step . There is no termination of execution.

Hard Assert: Verify certain test conditions are true or false . If it is passed move on with next step. If fail abort the execution.

3. Does Selenium provide these assertion libraries ?

  1. No. 
  2. TestNG provides

4. What is the difference between assert and verify?

  1. assert : check whether the expected condition is met or not. If it is false it it will terminate the execution. 
  2. verify: check whether the expected condition is true or false. If false test will continue, if true test will continue. There is no termination. 

5. Your team needs to check if a warning message is displayed when the password entered by the user is moderately secure. There are different datasets, where some passwords entered by the user are secure, so the warning message does not appear on the page. This should not halt the execution of the next steps in the test script. Can we use Assert commands to test this scenario?

No, we cannot use assert commands as they halt the further steps of the execution, in case of an assertion failure. Instead, we can use the verify command in this case. Verify commands, check the conditions if they are true or false, and also all the test phases get executed.

6. How to check if a logo is available?

Boolean value = driver.findElement(By.xpath("//div[@class='row'])).isDisplayed()
assertTrue(value, "
Not displayed")

No comments:

Post a Comment

Cucumber

What is Cucumber? Definition : Cucumber is an open-source tool that supports BDD . Purpose : Bridges the communication gap between business ...