testing.CustomerLoginTest.java Source code

Java tutorial

Introduction

Here is the source code for testing.CustomerLoginTest.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package testing;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

/**
 *
 * @author Nickolas
 */
public class CustomerLoginTest {
    private static WebDriver driver = null;

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "web/WEB-INF/chromedriver.exe");
        // TODO code application logic here
        // Initialize driver      
        driver = new ChromeDriver();

        //Go to URL      
        driver.get("http://localhost:8080/IowaAir/logIn.jsp");
        driver.manage().window().maximize();

        driver.findElement(By.xpath("/html/body/div[2]/form/input[1]")).sendKeys("beer@iowaair.net");
        driver.findElement(By.xpath("/html/body/div[2]/form/input[2]")).sendKeys("password");
        driver.findElement(By.xpath("/html/body/div[2]/form/input[3]")).click();

        String url = driver.getCurrentUrl();
        if (url.equals("http://localhost:8080/IowaAir/home.jsp")) {
            System.out.println("Login Successful");
        } else {
            System.out.println("Login failed");
        }
        driver.quit();
    }

}