Example usage for org.openqa.selenium.chrome ChromeDriver ChromeDriver

List of usage examples for org.openqa.selenium.chrome ChromeDriver ChromeDriver

Introduction

In this page you can find the example usage for org.openqa.selenium.chrome ChromeDriver ChromeDriver.

Prototype

public ChromeDriver() 

Source Link

Document

Creates a new ChromeDriver using the ChromeDriverService#createDefaultService default server configuration.

Usage

From source file:test.WS209.java

public static void main(String[] args) throws InterruptedException {
    // Create WebDriver Object 
    System.setProperty("webdriver.chrome.driver", "/Users/kristina_sinelnikova/Downloads/chromedriver");
    ChromeDriver driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    //Go to Login Page of TestWave
    driver.get("http://testwave.qabidder.net/#/page/login");

    //Login into TestWave
    WebElement usernameTextBox = driver.findElement(By.id("exampleInputEmail1"));
    usernameTextBox.sendKeys("ubertesterqa@gmail.com");
    WebElement passwordTextBox = driver.findElement(By.id("exampleInputPassword1"));
    passwordTextBox.sendKeys("12345password");

    Thread.sleep(3000);/* ww  w.j a  v a2s.c om*/
    WebElement loginButton = driver.findElement(By.tagName("button"));
    loginButton.click();

    Thread.sleep(3000);
    WebElement reports = driver.findElement(By.linkText("Add Report"));
    reports.click();

    Thread.sleep(3000);
    WebElement vehicleToolTip = driver
            .findElement(By.xpath("html/body/div[2]/section/div[1]/div/form/div[1]/div[2]/ol/li[6]"));
    vehicleToolTip.click();

    //Enter and clear vehicle information
    WebElement vehicleLicense = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleLicense']"));
    vehicleLicense.sendKeys("Y333YYY");
    vehicleLicense.clear();

    WebElement vehicleMake = driver.findElement(By.cssSelector("input[ng-model='wizard.report.vehicleMake']"));
    vehicleMake.sendKeys("Toyota");
    vehicleMake.clear();

    WebElement vehicleModel = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleModel']"));
    vehicleModel.sendKeys("Rav4");
    vehicleModel.clear();

    WebElement vehicleBodystyle = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleBodystyle']"));
    vehicleBodystyle.sendKeys("SUV");
    vehicleBodystyle.clear();

    WebElement vehicleYear = driver.findElement(By.cssSelector("input[ng-model='wizard.report.vehicleYear']"));
    vehicleYear.sendKeys("2014");
    vehicleYear.clear();

    WebElement vehicleColor = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleColors']"));
    vehicleColor.sendKeys("Red");
    vehicleColor.clear();

    WebElement vehicleOddities = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleOddities']"));
    vehicleOddities.sendKeys("Pink license plate");
    vehicleOddities.clear();

}

From source file:test.WS211.java

public static void main(String[] args) throws InterruptedException {
    // Create WebDriver Object 
    System.setProperty("webdriver.chrome.driver", "/Users/kristina_sinelnikova/Downloads/chromedriver");
    ChromeDriver driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    //Go to Login Page of TestWave
    driver.get("http://testwave.qabidder.net/#/page/login");

    //Login into TestWave
    WebElement usernameTextBox = driver.findElement(By.id("exampleInputEmail1"));
    usernameTextBox.sendKeys("ubertesterqa@gmail.com");
    WebElement passwordTextBox = driver.findElement(By.id("exampleInputPassword1"));
    passwordTextBox.sendKeys("12345password");

    Thread.sleep(3000);/*from  w  ww .j ava  2  s  . com*/
    WebElement loginButton = driver.findElement(By.tagName("button"));
    loginButton.click();

    Thread.sleep(3000);
    WebElement reports = driver.findElement(By.linkText("Add Report"));
    reports.click();

    Thread.sleep(3000);
    WebElement vehicleToolTip = driver
            .findElement(By.xpath("html/body/div[2]/section/div[1]/div/form/div[1]/div[2]/ol/li[6]"));
    vehicleToolTip.click();

    WebElement vehicleLicense = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleLicense']"));
    vehicleLicense.sendKeys("Y333YYY");

    WebElement vehicleMake = driver.findElement(By.cssSelector("input[ng-model='wizard.report.vehicleMake']"));
    vehicleMake.sendKeys("Toyota");

    WebElement vehicleModel = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleModel']"));
    vehicleModel.sendKeys("Rav4");

    WebElement vehicleBodystyle = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleBodystyle']"));
    vehicleBodystyle.sendKeys("SUV");

    WebElement vehicleYear = driver.findElement(By.cssSelector("input[ng-model='wizard.report.vehicleYear']"));
    vehicleYear.sendKeys("2014");

    WebElement vehicleColor = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleColors']"));
    vehicleColor.sendKeys("Red");

    Select dropdown = new Select(
            driver.findElement(By.cssSelector("select[ng-model='wizard.report.vehicleState']")));
    dropdown.selectByValue("CA");

    WebElement vehicleOddities = driver
            .findElement(By.cssSelector("input[ng-model='wizard.report.vehicleOddities']"));
    vehicleOddities.sendKeys("Pink license plate");

    Thread.sleep(3000);
    WebElement previewToolTip = driver
            .findElement(By.xpath("html/body/div[2]/section/div/div/form/div[1]/div[2]/ol/li[8]/h4/div"));
    previewToolTip.click();

}

From source file:testbench.org.rapidpm.jumpstart.vaadin.ui.BaseTestbenchTest.java

License:Apache License

private RemoteWebDriver getRemoteWebDriver() {

    String webDriver = System.getProperty(VAADIN_TESTBENCH_DRIVER_PROPERTY, DEAFAULT_WEB_DRIVER);
    RemoteWebDriver remoteWebDriver;/*  ww w  .  java 2  s.  c  om*/
    switch (webDriver.toLowerCase()) {
    case FIREFOX:
        remoteWebDriver = new FirefoxDriver();
        break;
    case CHROME:
        remoteWebDriver = new ChromeDriver();
        break;
    case PHANTOMJS:
        remoteWebDriver = new PhantomJSDriver();
        break;
    default:
        remoteWebDriver = new FirefoxDriver();
    }
    return remoteWebDriver;
}

From source file:TestCases.FirstTestCase.java

@Given("^Run Whit \"([^\"]*)\"$")
public void run_Whit(String arg1) throws Throwable {
    String Browser = arg1;//from  w  w  w.j  a  v a2  s  .  co  m
    switch (Browser.toLowerCase()) {
    case "chrome":
        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
        driver = new ChromeDriver();
        break;
    case "firefox":
        driver = new FirefoxDriver();
        break;
    case "ie":
        driver = new InternetExplorerDriver();
        break;
    default:
        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
        driver = new ChromeDriver();
        break;
    }

}

From source file:testHelper.WebDriverHelper.java

public static WebDriver getDriver() {
    WebDriver driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(TestConstants.IMPLICIT__WAIT_SECONDS, TimeUnit.SECONDS);
    return driver;
}

From source file:testing.AdminAirplaneTest.java

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("nickolas-kutsch@uiowa.edu");
    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/adminLanding.jsp")) {
        System.out.println("Login Successful");
        driver.findElement(By.xpath("/html/body/div[2]/ul/li[3]/a")).click();
        url = driver.getCurrentUrl();/*w w w. ja va2  s .c om*/
        if (url.equals("http://localhost:8080/IowaAir/adminAirplanes.jsp")) {
            System.out.println("Admin Airplane successful");
            Select aircraftType = new Select(driver.findElement(By.xpath("//*[@id=\"select_plane_name\"]")));
            aircraftType.selectByVisibleText("Boeing787-10");
            driver.findElement(By.xpath("/html/body/div[3]/form[1]/input")).click();
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[2]")).sendKeys("PL10007");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[8]")).click();
            url = driver.getCurrentUrl();
            if (url.equals("http://localhost:8080/IowaAir/adminAirplanes.jsp")) {
                System.out.println("Adding of Airplane successful");
                driver.findElement(By.xpath("/html/body/div[4]/table/tbody/tr[2]/td[9]/input")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/modifyAircraft.jsp")) {
                    System.out.println("Update Airplane Page Successful");
                    driver.findElement(By.xpath("//*[@id=\"downTimeID\"]")).sendKeys("65");
                    driver.findElement(By.xpath("/html/body/div[2]/form/input[15]")).click();
                    url = driver.getCurrentUrl();
                    if (url.equals("http://localhost:8080/IowaAir/adminAirplanes.jsp")) {
                        System.out.println("Update Airplane Successful");
                        driver.findElement(By.xpath("/html/body/div[3]/form[2]/a")).click();
                        url = driver.getCurrentUrl();
                        if (url.equals("http://localhost:8080/IowaAir/deleteAircraft.jsp")) {
                            System.out.println("Delete Airplane Page Successful");
                            driver.findElement(By.xpath("/html/body/div[2]/form/a")).click();
                            url = driver.getCurrentUrl();
                            if (url.equals("http://localhost:8080/IowaAir/adminAirplanes.jsp")) {
                                System.out.println("Go Back Successful");
                            } else {
                                System.out.println("Go Back Failed");
                            }
                        } else {
                            System.out.println("Delete Airplane Page Failed");
                        }
                    } else {
                        System.out.println("Update Airplane Failed");
                    }
                } else {
                    System.out.println("Update Airplane Page Failed");
                }
            } else {
                System.out.println("Adding of Airplane Failed");
            }
        } else {
            System.out.println("Admin Airplane Failed");
        }
    } else {
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.AdminAirportsTest.java

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("nickolas-kutsch@uiowa.edu");
    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/adminLanding.jsp")) {
        System.out.println("Login Successful");
        driver.findElement(By.xpath("/html/body/div[2]/ul/li[4]/a")).click();
        url = driver.getCurrentUrl();//from w  ww  . j  a v a2  s  .c  o m
        if (url.equals("http://localhost:8080/IowaAir/adminAirports.jsp")) {
            System.out.println("Airport page successful");
            driver.findElement(By.xpath("/html/body/div[3]/form/input[1]")).sendKeys("LAX");
            driver.findElement(By.xpath("/html/body/div[3]/form/input[2]")).sendKeys("Los Angeles");
            driver.findElement(By.xpath("/html/body/div[3]/form/input[3]")).sendKeys("California");
            driver.findElement(By.xpath("/html/body/div[3]/form/input[4]")).sendKeys("USA");
            driver.findElement(By.xpath("/html/body/div[3]/form/input[5]")).sendKeys("8");
            driver.findElement(By.xpath("/html/body/div[3]/form/input[6]")).click();
            url = driver.getCurrentUrl();
            if (url.equals("http://localhost:8080/IowaAir/adminAirports.jsp")) {
                System.out.println("Adding of Airport successful");
                driver.findElement(By.xpath("/html/body/div[3]/form/a")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/deleteAirport.jsp")) {
                    System.out.println("Delete Page Successful");
                    Select airportCode = new Select(driver.findElement(By.xpath("//*[@id=\"airportCodeID\"]")));
                    airportCode.selectByVisibleText("LAX");
                    driver.findElement(By.xpath("/html/body/div[2]/form/input")).click();
                    url = driver.getCurrentUrl();
                    if (url.equals("http://localhost:8080/IowaAir/adminAirports.jsp")) {
                        System.out.println("Deleted Aiprot Successful");
                    } else {
                        System.out.println("Deleted Aiprot failed");
                    }

                } else {
                    System.out.println("Delete Page failed");
                }

            } else {
                System.out.println("Adding of Airport failed");
            }

        } else {
            System.out.println("Airport page failed");
        }
    } else {
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.AdminEmployeeTest.java

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("nickolas-kutsch@uiowa.edu");
    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/adminLanding.jsp")) {
        System.out.println("Login Successful");
        driver.findElement(By.xpath("/html/body/div[2]/ul/li[5]/a")).click();
        url = driver.getCurrentUrl();/*www  .j  a  v  a 2 s .  c  o  m*/
        if (url.equals("http://localhost:8080/IowaAir/adminEmployees.jsp")) {
            System.out.println("Employee Page successful");
            driver.findElement(By.xpath("/html/body/div[3]/div[1]/form/input[1]")).sendKeys("Dylan");
            driver.findElement(By.xpath("/html/body/div[3]/div[1]/form/input[2]")).sendKeys("Kutsch");
            driver.findElement(By.xpath("/html/body/div[3]/div[1]/form/input[3]"))
                    .sendKeys("nickkutsch3@gmail.com");
            driver.findElement(By.xpath("/html/body/div[3]/div[1]/form/input[7]")).sendKeys("05/17/2000");
            driver.findElement(By.xpath("/html/body/div[3]/div[1]/form/input[8]")).click();
            url = driver.getCurrentUrl();
            if (url.equals("http://localhost:8080/IowaAir/adminEmployees.jsp")) {
                System.out.println("Adding of Employee successful");
                driver.findElement(By.xpath("/html/body/div[3]/div[1]/form/a")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/deleteEmployee.jsp")) {
                    System.out.println("Delete Employee Page successful");
                    Select email = new Select(driver.findElement(By.xpath("//*[@id=\"emailSelectedID\"]")));
                    email.selectByVisibleText("nickkutsch3@gmail.com");
                    driver.findElement(By.xpath("/html/body/div[2]/form/input")).click();
                    url = driver.getCurrentUrl();
                    if (url.equals("http://localhost:8080/IowaAir/adminEmployees.jsp")) {
                        System.out.println("Delete Employee Successful");

                    } else {
                        System.out.println("Delete Employee Failed");
                    }
                } else {
                    System.out.println("Delete Employee Page failed");
                }
            } else {
                System.out.println("Adding of Employee failed");
            }
        } else {
            System.out.println("Employee Page failed");
        }

    } else {
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.AdminFlightTest.java

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("nickolas-kutsch@uiowa.edu");
    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/adminLanding.jsp")) {
        System.out.println("Login Successful");
        driver.findElement(By.xpath("/html/body/div[2]/ul/li[2]/a")).click();
        url = driver.getCurrentUrl();//from   ww  w  . j  av a2 s.  com
        if (url.equals("http://localhost:8080/IowaAir/adminFlights.jsp")) {
            System.out.println("Admin Flights Successful");
            Select aircraftType = new Select(driver.findElement(By.xpath("/html/body/div[3]/form[1]/select")));
            aircraftType.selectByVisibleText("Boeing787-10");
            driver.findElement(By.xpath("/html/body/div[3]/form[1]/input")).click();
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[1]")).sendKeys("AA301");
            Select airplaneID = new Select(driver.findElement(By.xpath("//*[@id=\"aircraftID\"]")));
            airplaneID.selectByVisibleText("10003");
            Select originCode = new Select(driver.findElement(By.xpath("/html/body/div[3]/form[2]/select[2]")));
            originCode.selectByVisibleText("ORD");
            Select destinationCode = new Select(
                    driver.findElement(By.xpath("/html/body/div[3]/form[2]/select[3]")));
            destinationCode.selectByVisibleText("SFO");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[2]")).sendKeys("04/17/2017");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[3]")).sendKeys("04/17/2017");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[4]")).sendKeys("0600PM");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[5]")).sendKeys("1000PM");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[6]")).sendKeys("240");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[7]")).sendKeys("300");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[8]")).sendKeys("450");
            driver.findElement(By.xpath("/html/body/div[3]/form[2]/input[11]")).click();
            url = driver.getCurrentUrl();
            if (url.equals("http://localhost:8080/IowaAir/adminFlights.jsp")) {
                System.out.println("Adding of Flight Successful");
                driver.findElement(By.xpath("/html/body/div[4]/table/tbody/tr[3]/td[13]/button")).click();
                url = driver.getCurrentUrl();
                if (url.equals("http://localhost:8080/IowaAir/modifyFlight.jsp")) {
                    System.out.println("Update flight page successful");
                    driver.findElement(By.xpath("//*[@id=\"priceEconomyID\"]")).sendKeys("250");
                    driver.findElement(By.xpath("//*[@id=\"priceFirstClassID\"]")).sendKeys("450");
                    driver.findElement(By.xpath("//*[@id=\"modifyForm\"]/input[25]")).click();
                    url = driver.getCurrentUrl();
                    if (url.equals("http://localhost:8080/IowaAir/adminFlights.jsp")) {
                        System.out.println("Updated Flight Successful");
                        driver.findElement(By.xpath("/html/body/div[3]/form[2]/a")).click();
                        url = driver.getCurrentUrl();
                        if (url.equals("http://localhost:8080/IowaAir/deleteFlight.jsp")) {
                            System.out.println("Admin Flight Delete Page Successful");
                            Select flightNumber = new Select(
                                    driver.findElement(By.xpath("//*[@id=\"flightNumID\"]")));
                            flightNumber.selectByVisibleText("AA301");
                            driver.findElement(By.xpath("/html/body/div[2]/form/input")).click();
                            url = driver.getCurrentUrl();
                            if (url.equals("http://localhost:8080/IowaAir/adminFlights.jsp")) {
                                System.out.println("Flight Deleted Successfully");
                            } else {
                                System.out.println("Flight Deleted Failed");
                            }
                        } else {
                            System.out.println("Admin Flight Delete Page Failed");
                        }
                    } else {
                        System.out.println("Updated Flight Failed");
                    }
                } else {
                    System.out.println("Update flight page failed");
                }
            } else {
                System.out.println("Adding of Flight Failed");
            }

        } else {
            System.out.println("Admin Flights Failed");
        }
    } else {
        System.out.println("Login failed");
    }
    driver.quit();
}

From source file:testing.AdminLoginTest.java

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("nickolas-kutsch@uiowa.edu");
    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/adminLanding.jsp")) {
        System.out.println("Login Successful");
    } else {/*w  w w  .j a  va2 s  .  c  o  m*/
        System.out.println("Login failed");
    }
    driver.quit();
}