Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
147 views
in selenium-and-webdriver by The go-to Tester (181 points)
edited by

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.

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)
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!


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...