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

1 like 0 dislike
254 views
by The go-to Tester (344 points)
What is the use of @Test annotation and how can we use it in our tests in TestNG

1 Answer

0 like 0 dislike
by The go-to Tester (473 points)
selected by
 
Best answer

Any method with preannotation "@Test" consider as test case in that program.

Program can have any number of such methods with annotation @Test which will run one by one.

Inside the method with annotation @Test, we write our whole script for single test case.

Ex: 

   

 
@Test(priority=0)
@Parameters ({"sBrowser"})
public void alreadyLoggedIn(String browser)
{
//Execute it if user is already logged in
Reporter.log("I am in "+browser);
try {
if(!ele1.getText().equalsIgnoreCase("Visitante"))
 
{
   act1=builder.moveToElement(ele1).build();
   act1.perform();
   driver.findElement(By.linkText("Sair")).click();
   Log.info("Already Logged in user successfully LOGOUT");
   driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
}
} catch (Exception e) {
Log.info(e.toString());
}
 
 
}

 


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!

...