power_settings_new

I am writinng few tests. I see that there are places where the test automation engineer has used Assert and many other places the engineer has used Verify.

I would like to know the difference and how that will affect tests.

Eg.

Login script:

I enter the username and the password.

Assert the dashboard is loaded.

Login login = new Login(driver);
login.perform("admin", "admin");
Assert.assertTrue(Dashboard.getWelcomeMessage(driver).getText().contains("Welcome"));

Verifying the footer link:

if(isElementPresent(By.linkText("some footer link"))){
System.out.println("the Link found");
}
else{
System.out.println("the Link not found");
}
 
Kindly advise.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

answered by (171 points)
0 votes
When you assert an element or text you make sure that that text / element is present. If not, there is not point in continuing the test.

Eg. After executing login, if dashboard is not loaded, there is no point in continuing the test case.

But,

In second scenario, you are asserting footer links. Absence of the footer link does not really harm your execution, but thats an error. So you may want to continue your execution, but log the error. In that case we just verify if the element/text is present.

Hope that helps!
add
...