Example usage for org.openqa.selenium WebDriver manage

List of usage examples for org.openqa.selenium WebDriver manage

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriver manage.

Prototype

Options manage();

Source Link

Document

Gets the Option interface

Usage

From source file:RegisterCH.java

public static void main(String[] args) throws InterruptedException {
    // Optional, if not specified, WebDriver will search your path for Chrome driver

    System.setProperty("webdriver.chrome.driver", "/Users/tatianakesler/Desktop/Selenium/chromedriver");
    WebDriver wd = new ChromeDriver();
    wd.get(baseURL);/* ww  w.  j a va2 s .c o m*/
    wd.manage().window().maximize();

    //@CONSUMER_NO_BOAT_REG

    //Click SignUp as a consumer
    wd.findElement(By.id("btnRegister")).click();
    wd.findElement(By.id("personalTab")).click();

    //Type 1st, last , display name 
    wd.findElement(By.id("FirstNameOwner")).sendKeys(new String[] { Name1 });
    wd.findElement(By.id("LastNameOwner")).sendKeys(new String[] { Last1 });
    wd.findElement(By.id("DisplayNameOwner")).sendKeys(new String[] { DisplayName1 });

    //Type in email and confirm email
    wd.findElement(By.id("EmailOwner")).sendKeys(new String[] { Email1 });
    wd.findElement(By.id("EmailConfirmOwner")).sendKeys(new String[] { Email1 });

    //Type in Password and confirm password
    wd.findElement(By.id("PasswordOwner")).sendKeys(new String[] { Pass });
    wd.findElement(By.id("PasswordConfirmOwner")).sendKeys(new String[] { Pass });

    //Type a zip code
    wd.findElement(By.id("ZipCodeOwner")).sendKeys(new String[] { "33480" });

    //Uncheck im a boat Owner
    wd.findElement(By.id("IsBoatOwner")).click();

    //Check terms of use
    wd.findElement(By.id("termsOfUse")).click();

    //Click SignUp
    wd.findElement(By.id("btnSaveData")).click();

    Thread.sleep(7000);

    //Verify My Stuff tab

    //Verify client's name
    if (wd.getPageSource().contains(DisplayName1)) {
        System.out.println("- Client (No boat) Registered - PASS ");
        System.out.println("- Client name verified - " + DisplayName1 + " - PASS ");
    } else {
        System.out.println("- Client name verified - " + DisplayName1 + " - FAIL ");
    }

    //Verify My Stuff tab
    if (wd.getPageSource().contains("My Stuff")) {
        System.out.println("- My Stuff tab verified (no boat) - PASS ");
    } else {
        System.out.println("- My Stuff tab not found (no boat) - FAIL ");
    }

    //Close pop-up and logout and Logout
    if (wd.getPageSource().contains("glyphicon glyphicon-remove-circle")) {
        wd.findElement(By.xpath("//i[@class= 'glyphicon glyphicon-remove-circle']")).click();

        //Logout();
        Actions action1 = new Actions(wd);
        WebElement elems01 = wd.findElement(By.id("navTopRightMenuDisplayName"));
        Thread.sleep(3000);
        WebElement elems001 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]"));
        action1.moveToElement(elems01).click().perform();
        Thread.sleep(2000);
        action1.moveToElement(elems001).click().perform();

    } else {
        //Logout();
        Actions action1 = new Actions(wd);
        WebElement elems01 = wd.findElement(By.id("navTopRightMenuDisplayName"));
        Thread.sleep(3000);
        WebElement elems001 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]"));
        action1.moveToElement(elems01).click().perform();
        Thread.sleep(2000);
        action1.moveToElement(elems001).click().perform();
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////     

    //CONSUMER WITH BOAT REG

    //wd.get("http://qa.app.mytaskit.com");

    //Click SignUp as a consumer
    wd.findElement(By.id("btnRegister")).click();

    wd.findElement(By.id("personalTab")).click();

    //Type 1st, last , display name 
    wd.findElement(By.id("FirstNameOwner")).sendKeys(new String[] { Name1 });
    wd.findElement(By.id("LastNameOwner")).sendKeys(new String[] { Last1 });
    wd.findElement(By.id("DisplayNameOwner")).sendKeys(new String[] { DisplayName2 });

    //Type in email and confirm email
    wd.findElement(By.id("EmailOwner")).sendKeys(new String[] { Email2 });
    wd.findElement(By.id("EmailConfirmOwner")).sendKeys(new String[] { Email2 });

    //Type in Password and confirm password
    wd.findElement(By.id("PasswordOwner")).sendKeys(new String[] { Pass });
    wd.findElement(By.id("PasswordConfirmOwner")).sendKeys(new String[] { Pass });

    //Type a zip code
    wd.findElement(By.id("ZipCodeOwner")).sendKeys(new String[] { "33480" });

    //Type in boat info
    wd.findElement(By.id("BoatName")).sendKeys(new String[] { "Boat_automation" });
    wd.findElement(By.id("BoatManufacturer")).sendKeys(new String[] { "Volvo" });
    wd.findElement(By.id("BoatLength")).sendKeys(new String[] { "35" });

    //Check terms of use
    wd.findElement(By.id("termsOfUse")).click();

    //Click SignUp
    wd.findElement(By.id("btnSaveData")).click();

    Thread.sleep(7000);

    //Verify client's name
    if (wd.getPageSource().contains(DisplayName2)) {
        System.out.println("- Client boat owner Registered, client name verified - PASS ");
        System.out.println("- Client name verified - " + DisplayName2 + " - PASS ");
    } else {
        System.out.println("- Client no boat name shows up on the TM page " + DisplayName2 + " - Fail ");
    }

    //Verify My Stuff tab
    if (wd.getPageSource().contains("My Stuff")) {
        System.out.println("- My Stuff tab verified (boat owner) - PASS ");
    } else {
        System.out.println("- My Stuff tab not found (boat owner) - FAIL ");
    }

    //Close pop-up and logout and Logout
    //      if(wd.getPageSource().contains("glyphicon glyphicon-remove-circle"))
    //       {
    //          wd.findElement(By.xpath("//i[@class= 'glyphicon glyphicon-remove-circle']")).click();
    //          
    //          //Logout();
    //           Actions action2 = new Actions(wd);
    //           WebElement elems02 = wd.findElement(By.id("navTopRightMenuDisplayName"));
    //           Thread.sleep(3000);
    //           WebElement elems002 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]"));   
    //           action2.moveToElement(elems02).click().perform();
    //           Thread.sleep(2000);
    //           action2.moveToElement(elems002).click().perform();
    //           
    //       }
    //       else
    //       {
    //Logout();
    Actions action2 = new Actions(wd);
    WebElement elems02 = wd.findElement(By.id("navTopRightMenuDisplayName"));
    Thread.sleep(3000);
    WebElement elems002 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]"));
    action2.moveToElement(elems02).click().perform();
    Thread.sleep(2000);
    action2.moveToElement(elems002).click().perform();
    // }

    //FREE BUSINESS REGISTRATION 

    //Launch URL

    //Click SignUp as a business
    wd.findElement(By.id("btnRegister")).click();
    wd.findElement(By.id("businessTab")).click();

    //Type 1st, last , display name 
    wd.findElement(By.id("BusinessNameBiz")).sendKeys(new String[] { DisplayName3 });
    wd.findElement(By.id("DisplayNameBiz")).sendKeys(new String[] { DisplayName3 });

    //Type a ZIP code
    wd.findElement(By.id("ZipCodeBiz")).sendKeys(new String[] { "33480" });

    //Check Business type check-boxes
    wd.findElement(By.id("TypeIsBoatBuilder")).click();
    wd.findElement(By.id("TypeIsServiceYard")).click();
    wd.findElement(By.id("TypeIsYachtManagementCompany")).click();
    wd.findElement(By.id("TypeIsYachtManagementCompany")).click();
    wd.findElement(By.id("TypeIsEquipmentSupplier")).click();

    //Type in Administrator's 1st Name, last name
    wd.findElement(By.id("FirstNameBiz")).sendKeys(new String[] { Name1 });
    wd.findElement(By.id("LastNameBiz")).sendKeys(new String[] { Last1 });

    //Type in email and confirm email
    wd.findElement(By.id("EmailBiz")).sendKeys(new String[] { Email3 });
    wd.findElement(By.id("EmailConfirmBiz")).sendKeys(new String[] { Email3 });

    //Type in Password and confirm password
    wd.findElement(By.id("PasswordBiz")).sendKeys(new String[] { Pass });
    wd.findElement(By.id("PasswordConfirmBiz")).sendKeys(new String[] { Pass });

    //Check terms of use
    wd.findElement(By.id("termsOfUse")).click();

    //Click SignUp
    wd.findElement(By.id("btnSaveData")).click();

    Thread.sleep(3000);

    //Verify that is is a free business account 
    if (wd.getPageSource().contains("Get Professional")) {
        System.out.println("- Free Business Registration - PASS ");
        System.out.println("- Get Professional button verified - PASS ");

    } else {
        System.out.println("- Free Business was NOT registered  " + DisplayName3 + " - Fail ");
        System.out.println("- Get Professional button NOT verified - PASS ");
    }

    //Verify user name
    if (wd.getPageSource().contains(DisplayName3)) {
        System.out.println("- Free Business name verified - " + DisplayName3 + " - PASS ");
    } else {
        System.out.println("- User name not verified " + DisplayName3 + " - Fail ");
    }

    //Close pop-up and logout and Logout
    //   if(wd.getPageSource().contains("glyphicon glyphicon-remove-circle"))

    //Logout();
    Actions action1 = new Actions(wd);
    WebElement elems01 = wd.findElement(By.id("navTopRightMenuDisplayName"));
    Thread.sleep(3000);
    WebElement elems001 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]"));
    action1.moveToElement(elems01).click().perform();
    Thread.sleep(2000);
    action1.moveToElement(elems001).click().perform();
    // }

    // FREE BUSINSS UPGRADE TO PRO option 1 -Annual 

    //Launch URL
    //  wd.get("http://qa.app.mytaskit.com");
    //Thread.sleep(3000);

    //Login as free business
    wd.findElement(By.id("login_email")).sendKeys(new String[] { Email3 });
    wd.findElement(By.id("login_password")).sendKeys(new String[] { Pass });
    wd.findElement(By.xpath("//*[contains(text(), 'Login')]")).click();

    Thread.sleep(3000);

    //Close pop-up and logout and Logout

    //Click Upgrade to Pro
    wd.findElement(By.id("getProfessionalBtn")).click(); //-----------------------------UPGRADE TO PRO

    //Type in PROMO CODE and click Apply
    wd.findElement(By.id("promo-code")).sendKeys(new String[] { "mvf&f" });
    wd.findElement(By.id("btnVerify")).click();

    Thread.sleep(3000);

    //Select licenses
    wd.findElement(By.id("licenses")).sendKeys(new String[] { "25" });

    //Select Billing Cycle and Payment Details - Annual   
    wd.findElement(By.id("billing-cycle-2")).click();

    //Type in address / Phone    
    wd.findElement(By.id("addManualAddress_addressLookup")).click();
    //Street address
    wd.findElement(By.id("address")).sendKeys(new String[] { "1115 45th Street" });
    //City
    wd.findElement(By.id("city")).sendKeys(new String[] { "West Palm Beach" });
    //Country
    wd.findElement(By.id("CountrySelect")).sendKeys(new String[] { "United States" });
    //ZIP CODE
    wd.findElement(By.id("zip-code")).sendKeys(new String[] { "33407" });
    //State
    wd.findElement(By.id("StateSelect")).sendKeys(new String[] { "FL" });
    //Phone
    wd.findElement(By.id("phone")).sendKeys(new String[] { "1234567890" });

    // Click submit payment
    wd.findElement(By.id("btnEnroll")).click();

    //Close Grid Modal
    //wd.findElement(By.xpath("/html/body/div[10]/div/div/div[3]/div/button[1]")).click();

    Thread.sleep(2000);

    //Verify that Boat has been added

    if (wd.getPageSource().contains("Get Professional")) {
        System.out.println("- Free business Upgrade to PRO (Annual) - FAIL");
    } else {
        System.out.println("- Free business Upgrade to PRO (Annual) - PASS");
    }

    Actions action3 = new Actions(wd);
    WebElement elems03 = wd.findElement(By.id("navTopRightMenuDisplayName"));
    WebElement elems003 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]"));
    action3.moveToElement(elems03).click().perform();
    Thread.sleep(2000);
    action3.moveToElement(elems003).click().perform();

    Thread.sleep(4000);

    /////////////////SELECT DIFFERENT PRICE OPTIONS/////////////////////////////////////////////////////////////////////////////////////////////////////////
    //SELECT DIFFERENT PRICE OPTIONS
    //Launch URL

    //Click SignUp as a business
    wd.findElement(By.id("btnRegister")).click();
    wd.findElement(By.id("businessTab")).click();

    //Type 1st, last , display name 
    wd.findElement(By.id("BusinessNameBiz")).sendKeys(new String[] { DisplayName4 });
    wd.findElement(By.id("DisplayNameBiz")).sendKeys(new String[] { DisplayName4 });

    //Type a ZIP code
    wd.findElement(By.id("ZipCodeBiz")).sendKeys(new String[] { "33480" });

    //Check Business type check-boxes
    wd.findElement(By.id("TypeIsBoatBuilder")).click();
    wd.findElement(By.id("TypeIsServiceYard")).click();
    wd.findElement(By.id("TypeIsYachtManagementCompany")).click();
    wd.findElement(By.id("TypeIsYachtManagementCompany")).click();
    wd.findElement(By.id("TypeIsEquipmentSupplier")).click();

    //Type in Administrator's 1st Name, last name
    wd.findElement(By.id("FirstNameBiz")).sendKeys(new String[] { Name1 });
    wd.findElement(By.id("LastNameBiz")).sendKeys(new String[] { Last1 });

    //Type in email and confirm email
    wd.findElement(By.id("EmailBiz")).sendKeys(new String[] { Email4 });
    wd.findElement(By.id("EmailConfirmBiz")).sendKeys(new String[] { Email4 });

    //Type in Password and confirm password
    wd.findElement(By.id("PasswordBiz")).sendKeys(new String[] { Pass });
    wd.findElement(By.id("PasswordConfirmBiz")).sendKeys(new String[] { Pass });

    //Check terms of use
    wd.findElement(By.id("termsOfUse")).click();

    //Click SignUp
    wd.findElement(By.id("btnSaveData")).click();

    Thread.sleep(3000);
    //Close pop-up and logout and Logout
    //  wd.findElement(By.xpath("//i[@class= 'glyphicon glyphicon-remove-circle']")).click();

    //////////////////UPGRADE/////////////////////////////////////////////////////////////////////////////////////////   
    Thread.sleep(2000);
    //Click Upgrade to Pro
    wd.findElement(By.id("getProfessionalBtn")).click(); //-----------------------------UPGRADE TO PRO

    Thread.sleep(3000);

    //Type in PROMO CODE and click Apply
    wd.findElement(By.id("promo-code")).sendKeys(new String[] { "mvf&f" });
    wd.findElement(By.id("btnVerify")).click();

    Thread.sleep(3000);

    //Select licenses
    wd.findElement(By.id("licenses")).sendKeys(new String[] { "15" });

    //Select Billing Cycle and Payment Details - Annual   
    wd.findElement(By.id("billing-cycle-1")).click();

    //Type in address / Phone    
    wd.findElement(By.id("addManualAddress_addressLookup")).click();
    //Street address
    wd.findElement(By.id("address")).sendKeys(new String[] { "1115 45th Street" });
    //City
    wd.findElement(By.id("city")).sendKeys(new String[] { "West Palm Beach" });
    //Country
    wd.findElement(By.id("CountrySelect")).sendKeys(new String[] { "United States" });
    //ZIP CODE
    wd.findElement(By.id("zip-code")).sendKeys(new String[] { "33407" });
    //State
    wd.findElement(By.id("StateSelect")).sendKeys(new String[] { "FL" });
    //Phone
    wd.findElement(By.id("phone")).sendKeys(new String[] { "1234567890" });

    // Click submit payment
    wd.findElement(By.id("btnEnroll")).click();

    Thread.sleep(4000);

    //Verify that Boat has been added
    if (wd.getPageSource().contains("Get Professional")) {
        System.out.println("- Free Business upgrade to PRO (Monthly) - FAIL");
    } else {
        System.out.println("- Free Business upgrade to PRO (Monthly) - PASS");
    }

    Thread.sleep(2000);

    Actions action6 = new Actions(wd);
    WebElement elems06 = wd.findElement(By.id("navTopRightMenuDisplayName"));
    WebElement elems006 = wd.findElement(By.xpath("(//a[contains(text(),'Logout')])[2]"));
    action6.moveToElement(elems06).click().perform();
    Thread.sleep(2000);
    action6.moveToElement(elems006).click().perform();

    Thread.sleep(5000);

    wd.close();
}

From source file:ClientServicesQA.java

public void loginToClientServices(String url, WebDriver driver) throws InterruptedException {
    String institutionName = "Client Services";
    String userName = "MHCampusAutomationAdmin";
    String password = "12345678";

    driver.manage().window().maximize();
    driver.get(url);//w w  w . j av  a  2 s. c om

    driver.findElement(By.id("TextBoxInstitution")).clear(); // clearing the institution text box
    driver.findElement(By.id("TextBoxInstitution")).sendKeys(institutionName); // enter institution name
    driver.findElement(By.id("TextBoxUsername")).clear(); // enter user name
    driver.findElement(By.id("TextBoxUsername")).sendKeys(userName);// clearing the user name text box
    driver.findElement(By.id("TextBoxPassword")).clear(); // enter password
    driver.findElement(By.id("TextBoxPassword")).sendKeys(password);// clearing the password text box

    driver.findElement(By.id("ButtonLogin")).click(); //Clicking on the Login button

    Thread.sleep(2000);
    //driver.findElement(By.partialLinkText("Convert")).click(); // find element by partial text
    //driver.findElement(By.id("ctl00_LoginStatus1")).click();

    driver.close();
}

From source file:openCloseTables.java

public static void main(String[] args) throws IOException {

    System.setProperty("webdriver.ie.driver",
            "C:\\Users\\Colin Cook\\Desktop\\selenium-2.53.1\\IEDriverServer.exe");
    WebDriver driver = new InternetExplorerDriver();

    driver.get("http://10.0.1.53/opstar_test/");

    out.println("Launching Internet Explorer browser..");
    driver.manage().window().maximize();

    try {//from www .j  a  v  a  2  s  .c o m
        Thread.sleep(3000); // pauses for 3 seconds
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    out.println("The title of the page being tested is:   " + driver.getTitle());

    WebElement acknowledge = driver
            .findElement(By.xpath("html/body/div[5]/div[1]/div[2]/div[2]/div[1]/div/div[2]/center/a"));
    acknowledge.click(); //first popup when you go on site

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement applications = //driver.findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[5]/a/span"));
            driver.findElement(By.linkText("Applications"));
    applications.click();

    WebElement toTools = driver
            .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/a"));
    toTools.click();

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement traingFolder = driver
            .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/ul/li/a"));
    traingFolder.click();

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeBox = driver.findElement(By.id("cboxClose"));
    closeBox.click(); //clicks second popup acknolwedge box

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement textBox = driver.findElement(By
            .xpath("html/body/div[3]/div[4]/div[2]/div/div[1]/div/div[2]/div/form/div/div/span/span[1]/span"));
    textBox.click();

    textBox.sendKeys("ken"); //first three letters of someones name

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    textBox.sendKeys(Keys.ENTER);

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table1 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div/a[2]"));
    table1.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    table1.click();

    out.println("The Designations folder has been successfully opened and closed");
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table2 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]"));
    table2.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    table2.click();
    out.println("The Waivers folder has been successfully opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table3 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[1]/div/a[2]"));
    table3.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    table3.click();
    out.println("The Professional Licenses/ Certificates / Medical folder has been opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table4 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]"));
    table4.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    table4.click();
    out.println("The First Aid folder has been succesfully opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table5 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]"));
    table5.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    table5.click();
    out.println("The Star folder has been successfully opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table6 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]"));
    table6.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    table6.click();
    out.println("The Training Courses and Tests folder has been successfully opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table7 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]"));
    table7.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    table7.click();
    out.println(
            "The Professional Development / Individual Development Plan folder has been successfully opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table8 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]"));
    table8.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    table8.click();
    out.println("The FLETC Certificates folder has been successfully opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table9 = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]"));
    table9.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    table9.click();
    out.println("The Miscellaneous folder has been succesfully opened and closed");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement qualifications = driver
            .findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[1]/div/a[2]"));
    qualifications.click();

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    qualifications.click();
    out.println("The Qualifications folder has been successfully opened and closed");

    // I should program test scripts like this in the future

    //        try {
    //            WebElement xbox = driver.findElement(By.id("cboxClose"));
    //            xbox.click();
    //        } catch(Exception e) {
    //            System.err.print("NO NO NO that ");
    //        }

}

From source file:ToTrainingFolder.java

public static void main(String[] args) throws IOException {

    System.setProperty("webdriver.ie.driver",
            "C:\\Users\\Colin Cook\\Desktop\\Opstar Training Folder\\IEDriverServer.exe");
    WebDriver driver = new InternetExplorerDriver();

    driver.get("http://10.0.1.53/opstar_test/");

    out.println("Launching Internet Explorer browser..");
    driver.manage().window().maximize();
    try {/*  w ww .  ja  va 2 s  . c  o m*/
        Thread.sleep(1000); // pauses for 1 second
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    out.println("The title of the page being tested is:  " + driver.getTitle());

    WebElement acknowledge = driver
            .findElement(By.xpath("html/body/div[5]/div[1]/div[2]/div[2]/div[1]/div/div[2]/center/a"));
    acknowledge.click(); //first popup when you go on site
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement applications = driver.findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/a"));
    //driver.findElement(By.linkText("Training Folder"));
    System.out.println(applications.getText());
    applications.click();

    WebElement toTools = driver
            .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/a"));
    toTools.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement traingFolder = driver
            .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/ul/li/a"));
    traingFolder.click();
    System.out.println("The Training Folder has been selected");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeBox = driver.findElement(By.id("cboxClose"));
    closeBox.click(); //clicks second popup acknolwedge box
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement textBox = driver.findElement(By
            .xpath("html/body/div[3]/div[4]/div[2]/div/div[1]/div/div[2]/div/form/div/div/span/span[1]/span"));
    textBox.click();
    textBox.sendKeys("ken");
    textBox.sendKeys(Keys.ENTER);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    /***************
     THIS IS WHERE THE QUALIFICATIONS FOLDER STARTS
     ******************/

    WebElement image1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[1]/span/a/img"));
    image1.click();
    image1.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement table1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[2]/input"));
    table1.clear();
    table1.sendKeys("Testing table 1, Opstar Test");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement date1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[3]/input"));
    date1.click();
    date1.clear();
    date1.sendKeys("12/25/2016");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    // WebElement save = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[1]/div[5]/span[1]/i"));
    //save.click();

    WebElement image2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[1]/span/a/img"));
    image2.click();
    image2.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement title2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[2]/input"));
    title2.clear();
    title2.sendKeys("Testing table 2, Opstar test 2");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement date2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[3]/input"));
    date2.click();
    date2.clear();
    date2.sendKeys("01/01/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    // WebElement save2 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[2]/div[3]/div[3]/div[3]/div[5]/span[1]/i"));
    //save2.click();

    WebElement closeQualifications = driver
            .findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[1]/div/a[2]"));
    closeQualifications.click();

    System.out.println("The Qualifications folder has been tested");

    /***************
     THIS IS WHERE THE DESIGNATIONS FOLDER STARTS
     ******************/

    WebElement Designations = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    Designations.click();
    Designations.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement DesignationsTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[2]/input"));
    DesignationsTitle.clear();
    DesignationsTitle.sendKeys("Testing the Desiganations title box, Opstar Test");

    WebElement DesignationsIssue = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[3]/input"));

    DesignationsIssue.clear();
    DesignationsIssue.sendKeys("03/24/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    // WebElement saveDesignations = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[2]/table/tbody/tr/td[5]/span[1]/i"));
    //saveDesignations.click();

    WebElement closeDesignations = driver
            .findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[1]/div/div[1]/div/a[2]"));
    closeDesignations.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The Designations box has been tested");

    /***************
     THIS IS WHERE THE WAIVERS FOLDER STARTS
     ******************/

    WebElement waivers = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]"));
    waivers.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement waiversFile = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    waiversFile.click();
    waiversFile.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement waiversTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[2]/input"));
    waiversTitle.clear();
    waiversTitle.sendKeys("Testing the Waivers folder, Opstar test");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement issueDateWaivers = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[2]/table/tbody/tr/td[3]/input"));
    issueDateWaivers.clear();
    issueDateWaivers.sendKeys("01/16/2016");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    //WebElement saveWaivers = driver.findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[2]/div/div[2]/table/tbody/tr/td[5]/span[1]/i"));
    //saveWaivers.click();

    WebElement closeWaivers = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]"));
    closeWaivers.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The waivers folder has been tested");
    /***************
     THIS IS WHERE THE PROFESSIONAL LICENSES FOLDER STARTS
     ******************/

    WebElement proLicensesCert = driver
            .findElement(By.xpath(".//*[@id='student_folder_wrapper']/div[2]/div[3]/div/div[1]/div/a[2]"));
    proLicensesCert.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement imagePro = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    imagePro.click();
    imagePro.sendKeys(Keys.ESCAPE);

    WebElement proTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[2]/input"));
    proTitle.clear();
    proTitle.sendKeys("OpSTAR Automation testing this title box");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proIssueDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[2]/table/tbody/tr/td[3]/input"));
    proIssueDate.clear();
    proIssueDate.sendKeys("05/04/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proClose = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[1]/div/a[2]"));
    proClose.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The professional Licenses, Certificates, Medical folder has been tested");
    /***************
     THIS IS WHERE THE FIRSTAID FOLDER STARTS
     ******************/

    WebElement firstAid = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]"));
    firstAid.click();

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement firstAidImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    firstAidImage.click();
    firstAidImage.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement firstAidTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[2]/input"));
    firstAidTitle.clear();
    firstAidTitle.sendKeys("KeyBridge automation testing using Selenium");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement firstAidDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[2]/table/tbody/tr/td[3]/input"));
    firstAidDate.clear();
    firstAidDate.sendKeys("02/02/2017");
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeFirstAid = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]"));
    closeFirstAid.click();
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The First Aid folder has been tested");
    /***************
     THIS IS WHERE THE STAR FOLDER STARTS
     ******************/

    WebElement starOpen = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]"));
    starOpen.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement starImage1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[1]/span/a/img"));
    starImage1.click();
    starImage1.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement starTitle1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[2]/input"));
    starTitle1.clear();
    starTitle1.sendKeys("KeyBridge OpSTAR automation testing");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement starIssueDate1 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[1]/td[3]/input"));
    starIssueDate1.clear();
    starIssueDate1.sendKeys("03/17/2017");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement starTitle2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[2]/td[2]/input"));
    starTitle2.clear();
    starTitle2.sendKeys("CPB Automation Testing");

    // WebElement starIssueDate2 = driver.findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[2]/table/tbody/tr[2]/td[3]/input"));
    // starIssueDate2.click();

    WebElement closeStarFolder = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]"));
    closeStarFolder.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    System.out.println("The Star Folder has been tested");

    /***************
     THIS IS WHERE THE TRAINING COURSES AND TESTS FOLDER STARTS
     ******************/
    WebElement openCourseAndTests = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]"));
    openCourseAndTests.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement lastFive = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/h4/span[2]"));
    lastFive.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement showAll = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/h4/span[3]"));
    showAll.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeTrainingCourse = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]"));
    closeTrainingCourse.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    System.out.println("The Training Courses and Tests folder has been tested");
    /***************
     THIS IS WHERE THE PROFESSIONAL DEVELOPMENT FOLDER STARTS
     ******************/

    WebElement proDevelopment = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]"));
    proDevelopment.click();

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    proImage.click();
    proImage.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement proTitle2 = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[2]/input"));
    proTitle2.clear();
    proTitle2.sendKeys("Testing the PRO Development box");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement proDevelopmentDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[2]/table/tbody/tr/td[3]/input"));
    proDevelopmentDate.clear();
    proDevelopmentDate.sendKeys("03/24/2017");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeProDevelopment = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]"));
    closeProDevelopment.click();

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    System.out.println("The Professional Development / Individual Development Plan Folder has been tested");
    /***************
     THIS IS WHERE THE FLETC CERTIFICATES FOLDER STARTS
     ******************/

    WebElement fletcOpen = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]"));
    fletcOpen.click();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement fletcImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    fletcImage.click();
    fletcImage.sendKeys(Keys.ESCAPE);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement fletcTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[2]/input"));
    fletcTitle.clear();
    fletcTitle.sendKeys("Testing the FLETC Certificates folder");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement fletcDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[2]/table/tbody/tr/td[3]/input"));
    fletcDate.clear();
    fletcDate.sendKeys("03/24/2017");
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement closeFLETC = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]"));
    closeFLETC.click();

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    System.out.println("The FLETC Certificates Folder has been tested");
    /***************
     THIS IS WHERE THE MISCELLANEOUS CERTIFICATES FOLDER STARTS
     ******************/

    WebElement openMisc = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]"));
    openMisc.click();
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }

    WebElement miscImage = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[1]/span/a/img"));
    miscImage.click();
    miscImage.sendKeys(Keys.ESCAPE);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement miscTitle = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[2]/input"));
    miscTitle.clear();
    miscTitle.sendKeys("Testing the the Misc box");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement miscDate = driver.findElement(By.xpath(
            "html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[2]/table/tbody/tr/td[3]/input"));
    miscDate.clear();
    miscDate.sendKeys("12/25/2016");

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebElement closeMisc = driver.findElement(
            By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]"));
    closeMisc.click();
    System.out.println("The Miscellaneous folder has been tested");

    System.out.println("The Training Folder automation test has successfully passed!");

}

From source file:WaitTool.java

License:Open Source License

/**
 * Wait for the element to be present in the DOM, and displayed on the page.
 * And returns the first WebElement using the given method.
 *
 * @param WebDriver   The driver object to be used
 * @param By   selector to find the element
 * @param int   The time in seconds to wait until returning a failure
 *
 * @return WebElement   the first WebElement using the given method, or null (if the timeout is reached)
 *//* w w  w. ja  v  a2s .c  o  m*/
public static WebElement waitForElement(WebDriver driver, final By by, int timeOutInSeconds) {
    WebElement element;
    try {
        //To use WebDriverWait(), we would have to nullify implicitlyWait().
        //Because implicitlyWait time also set "driver.findElement()" wait time.
        //info from: https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/6VO_7IXylgY
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait()

        WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
        element = wait.until(ExpectedConditions.visibilityOfElementLocated(by));

        driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait
        return element; //return the element
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:WaitTool.java

License:Open Source License

/**
 * Wait for the element to be present in the DOM, regardless of being displayed or not.
 * And returns the first WebElement using the given method.
 *
 * @param WebDriver   The driver object to be used
 * @param By   selector to find the element
 * @param int   The time in seconds to wait until returning a failure
 *
 * @return WebElement   the first WebElement using the given method, or null (if the timeout is reached)
 *//*  www . jav a  2 s. co  m*/
public static WebElement waitForElementPresent(WebDriver driver, final By by, int timeOutInSeconds) {
    WebElement element;
    try {
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait()

        WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
        element = wait.until(ExpectedConditions.presenceOfElementLocated(by));

        driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait
        return element; //return the element
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:WaitTool.java

License:Open Source License

/**
 * Wait for the List<WebElement> to be present in the DOM, regardless of being displayed or not.
 * Returns all elements within the current page DOM.
 *
 * @param WebDriver   The driver object to be used
 * @param By   selector to find the element
 * @param int   The time in seconds to wait until returning a failure
 *
 * @return List<WebElement> all elements within the current page DOM, or null (if the timeout is reached)
 */// ww  w  .ja v a 2  s .  c  o m
public static List<WebElement> waitForListElementsPresent(WebDriver driver, final By by, int timeOutInSeconds) {
    List<WebElement> elements;
    try {
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait()

        WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
        wait.until((new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(WebDriver driverObject) {
                return areElementsPresent(driverObject, by);
            }
        }));

        elements = driver.findElements(by);
        driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait
        return elements; //return the element
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:WaitTool.java

License:Open Source License

/**
 * Wait for an element to appear on the refreshed web-page.
 * And returns the first WebElement using the given method.
 *
 * This method is to deal with dynamic pages.
 *
 * Some sites I (Mark) have tested have required a page refresh to add additional elements to the DOM.
 * Generally you (Chon) wouldn't need to do this in a typical AJAX scenario.
 *
 * @param WebDriver   The driver object to use to perform this element search
 * @param locator   selector to find the element
 * @param int   The time in seconds to wait until returning a failure
 *
 * @return WebElement   the first WebElement using the given method, or null(if the timeout is reached)
 *
 * @author Mark Collin//w ww  .j a v a  2s .  c o m
 */
public static WebElement waitForElementRefresh(WebDriver driver, final By by, int timeOutInSeconds) {
    WebElement element;
    try {
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait()
        new WebDriverWait(driver, timeOutInSeconds) {
        }.until(new ExpectedCondition<Boolean>() {

            @Override
            public Boolean apply(WebDriver driverObject) {
                driverObject.navigate().refresh(); //refresh the page ****************
                return isElementPresentAndDisplay(driverObject, by);
            }
        });
        element = driver.findElement(by);
        driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait
        return element; //return the element
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:WaitTool.java

License:Open Source License

/**
 * Wait for the Text to be present in the given element, regardless of being displayed or not.
 *
 * @param WebDriver   The driver object to be used to wait and find the element
 * @param locator   selector of the given element, which should contain the text
 * @param String   The text we are looking
 * @param int   The time in seconds to wait until returning a failure
 *
 * @return boolean//from  www  .j a v  a 2  s  .com
 */
public static boolean waitForTextPresent(WebDriver driver, final By by, final String text,
        int timeOutInSeconds) {
    boolean isPresent = false;
    try {
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait()
        new WebDriverWait(driver, timeOutInSeconds) {
        }.until(new ExpectedCondition<Boolean>() {

            @Override
            public Boolean apply(WebDriver driverObject) {
                return isTextPresent(driverObject, by, text); //is the Text in the DOM
            }
        });
        isPresent = isTextPresent(driver, by, text);
        driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait
        return isPresent;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}

From source file:WaitTool.java

License:Open Source License

/**
 * Waits for the Condition of JavaScript.
 *
 *
 * @param WebDriver      The driver object to be used to wait and find the element
 * @param String   The javaScript condition we are waiting. e.g. "return (xmlhttp.readyState >= 2 && xmlhttp.status == 200)"
 * @param int   The time in seconds to wait until returning a failure
 *
 * @return boolean true or false(condition fail, or if the timeout is reached)
 **//*from   w ww .ja v a 2s.  co  m*/
public static boolean waitForJavaScriptCondition(WebDriver driver, final String javaScript,
        int timeOutInSeconds) {
    boolean jscondition = false;
    try {
        driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait()
        new WebDriverWait(driver, timeOutInSeconds) {
        }.until(new ExpectedCondition<Boolean>() {

            @Override
            public Boolean apply(WebDriver driverObject) {
                return (Boolean) ((JavascriptExecutor) driverObject).executeScript(javaScript);
            }
        });
        jscondition = (Boolean) ((JavascriptExecutor) driver).executeScript(javaScript);
        driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait
        return jscondition;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}