package tests;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class LoginTest {
@Test
public void testLoginPageTitle() {
System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver");
WebDriver driver = new ChromeDriver();
try {
driver.get("https://example.com/login");
String title = driver.getTitle();
assertTrue(title.contains("Login"), "Page title should contain 'Login'");
} finally {
driver.quit();
}
}
}
/*
To run this test via Maven:
1. Open terminal in project root (where pom.xml is)
2. Run: mvn test
Expected console output includes:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running tests.LoginTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: X.XXX s
[INFO]
[INFO] BUILD SUCCESS
*/The test class LoginTest uses JUnit 5 and Selenium WebDriver.
We set the ChromeDriver system property to locate the driver executable.
The test opens the login page URL and checks the page title contains 'Login'.
Finally, the driver quits to close the browser.
Running mvn test in the project root triggers Maven Surefire plugin to compile and run this test.
The console output shows test progress and ends with BUILD SUCCESS if tests pass.