import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; import junit.framework.Assert; public class projectlogin { @Test public static void logintest() { // Step 0.1: Invoke the browser System.setProperty("webdriver.chrome.driver", "src//main//resources//chromedriver.exe"); WebDriver bank = new ChromeDriver(); login(bank); DayTwo(bank); } private static void login(WebDriver bank) { // Step 1: Open the Website String url = "https://www.demo.guru99.com/V4/"; bank.get(url); //Maximize Window bank.manage().window().maximize(); // Step 1: Enter the username // mngr288729 WebElement username = bank.findElement(By.xpath("//input[@name='uid']")); username.sendKeys("mngr288729"); // Step 2:Enter the password // upapAtE WebElement password = bank.findElement(By.xpath("//input[@name='password']")); password.sendKeys("upapAtE"); // Step 2: Click on Login Button WebElement button = bank.findElement(By.xpath("//input[@type='submit']")); button.click(); } public static void DayTwo(WebDriver bank) { // validate the Landing Page String expected_landing = "https://www.demo.guru99.com/V4/manager/Managerhomepage.php"; String actual_landing = bank.getCurrentUrl(); Assert.assertEquals(expected_landing, actual_landing, "The landing page is not correct"); System.out.println("The expected Page is correct"); //Close Window bank.close(); } }
Refer to the details of our Job Placement Program at:
Resolve6 Software QA Training and Job Placement Program with Selenium, JMeter, SOAPUI
Canada, Brampton, Mississauga, Toronto