package TestNG;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;
public class DemoTestNG {
// public void main(String[] args) {
// objects and variables instantiation
WebDriver driver = new FirefoxDriver();
// launch the firefox browser and open the application url
@Test
public void Sox_Login() {
driver.get(appUrl);
// maximize the browser window
driver.manage().window().maximize();
// declare and initialize the variable to store the expected title of the webpage.
String expectedTitle = "SOX ADMIN - LOGIN";
// fetch the title of the web page and save it into a string variable
String actualTitle = driver.getTitle();
Assert.assertEquals(expectedTitle,actualTitle);
// compare the expected title of the page with the actual title of the page and print the result
// if (expectedTitle.equals(actualTitle))
//{
// System.out.println("Verification Successful - The correct title is displayed on the web page.");
//}
// else
// {
// System.out.println("Verification Failed - An incorrect title is displayed on the web page.");
// }
// enter a valid username in the email textbox
WebElement username = driver.findElement(By.id("j_username"));
username.clear();
username.sendKeys(new String[]{"sox"});
// enter a valid password in the password textbox
WebElement password = driver.findElement(By.id("j_password"));
password.clear();
password.sendKeys(new String[]{"welcome@123"});
// click on the Sign in button
//WebElement SignInButton = driver.findElement(By.id("login_from_loginpage"));
WebElement SignInButton = driver.findElement(By.xpath("//*[@id='login-page']/div/form/div/button"));
SignInButton.click();
// close the web browser
driver.close();
System.out.println("Test script executed successfully.");
// terminate the program
System.exit(0);
}
}