Issue
I am trying to launch and close my browser after every @Test but i am unable to is the only solution to creat a new fuction .java and add my second @Test in it or can i do it in the same .java . I searched a littel bit but i keep finding @beforetest and @aftertest but those two only are executed once i want them to execute for every @test.
Example of my code : @BeforeTest public void LaunchBrowser() throws IOException { //Where i have my launch code }
@Test(priority = 1)
public void Commande_Simple_Mode_Connecte() throws InterruptedException {
Authentification(driver);
RechercheMarque(driver, "adidas");
SaisieArticle(driver);
AccesPanierSimple(driver);
ValidationCommandeSimple(driver);
}
@Test(priority = 2)
public void Commande_Simple_Etrangere_Mode_Deconnecte() throws InterruptedException {
RechercheArticleMD(driver,"ocstore");
SaisieArticleEtrangerMD(driver);
AccesPanierSimple(driver);
AuthentificationDepuisPanierDeconnecter(driver);
ValidationCommandeSimpleEtrangere(driver);
}
@AfterTest
public void CloseChrome() {
driver.quit();
}
Solution
Since you are using TestNG, I would consult its documentation, which points out these two annotations:
@BeforeMethod: The annotated method will be run before each test method.
@AfterMethod: The annotated method will be run after each test method.
It seems these should enable you to run code before or after each test method.
Answered By - Kendas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.