TestNG(TestNG XML File)
TestNG(TestNG XML File)
java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.*;
import java.time.Duration;
@AfterMethod
public void tearDown()
{
driver.close();
}
@Test
public void testLoginWithEmptyFields()
{
WebDriverWait wait = new WebDriverWait(driver,Duration.ofSeconds(10));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button.login-button")));
@Test
public void testLoginWithEmptyUserId()
{
WebElement pinField = driver.findElement(By.cssSelector("input#pinInput"));
pinField.sendKeys("231225");
@Test
public void testLoginWithEmptyPin()
{
WebElement userIdField = driver.findElement(By.cssSelector("input#userIdInput"));
userIdField.sendKeys("142420");
@Test
public void testLoginWithInvalidPin()
{
WebElement userIdField = driver.findElement(By.cssSelector("input#userIdInput"));
userIdField.sendKeys("142420");
@Test
public void testLoginWithValidCreds()
{
WebElement userIdField = driver.findElement(By.cssSelector("input#userIdInput"));
userIdField.sendKeys("142420");
}
}
HomePageTest.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.*;
import java.time.Duration;
@AfterMethod
public void tearDown()
{
driver.close();
}
@Test
public void testHomePageHeading()
{
WebElement userIdField = driver.findElement(By.cssSelector("input#userIdInput"));
userIdField.sendKeys("142420");
@Test
public void testLogoutFunctionality()
{
WebElement userIdField = driver.findElement(By.cssSelector("input#userIdInput"));
userIdField.sendKeys("142420");
testng.xml
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name = "EBank Test Suite" parallel="tests" thread-count="2">
<test name = "LoginPage">
<classes>
<class name="LoginPageTest"></class>
</classes>
</test>