How to run test cases in the same class in the sequence I want in the TestNG framework?
Hey Ian,
You need to set the priority along with the @Test annotation.
This can be done as follows:
@Test (priority=1), @Test (priority=2)
Consider the following Example:
@Test (priority=2)
public void getText()
{
driver.findElement(By.id(“id”)).getText();
}
@Test(priority=1)
public void clickelement()
{
driver.findElement(By.id(“id”)).click();
}
In the above example, clickelement()
will get executed first as the priority is set to 1.
And, getText()
will get executed after clickelement()
as its priority is set to 2.