Write three TestNG tests and use dependsOnMethods to define the dependencies between test methods.
Create four test methods: openbrowser(), login() and logout(), closebrowser(). These methods will run alphabetically by default.
Execute these methods using the TestNG dependency feature and ensure that login runs after openbrowser, logout runs after the login method, and closebrowser runs after logout.
package practice;
import org.testng.annotations.Test;
public class Exercise {
@Test
public void openbrowser() {
System.out.println("Opening Chrome Browser");
//write code
}
@Test(dependsOnMethods = "openbrowser")
public void login() {
System.out.println("Login page open");
//write code
}
@Test(dependsOnMethods = "login")
public void logout() {
System.out.println("Logout successfully");
//write code
}
@Test(dependsOnMethods = "logout")
public void closebrowser() {
System.out.println("Closing Browser");
//write code
}
}
Copyright © 2023 - Proleed Academy | All Rights Reserved.