Example usage for org.openqa.selenium WebDriver get

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

Introduction

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

Prototype

void get(String url);

Source Link

Document

Load a new web page in the current browser window.

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);
    wd.manage().window().maximize();//ww  w  . j  ava2  s. co m

    //@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:BallerinaEditorUITest.java

License:Open Source License

@Test(dataProvider = "getData")
public void openBallerinaFile(String fileName) throws IOException, InterruptedException,
        ParserConfigurationException, SAXException, TransformerException, URISyntaxException {

    //creating relevant browser webdriver
    //TODO make this generic for multiple browsers
    WebDriver driver = new FirefoxDriver();
    //opening base page - welcome page this case
    driver.get(TestConstants.SERVER_URL);
    //once the open button available click it
    waitAndGetElementByXpath(driver, TestConstants.WELCOME_PAGE_OPEN_BUTTON_XPATH).click();
    //fill the location of the ballerina file to be opened
    URL BallerinaResourceLocation = BallerinaEditorUITest.class
            .getResource(TestConstants.BALLERINA_RESOURCE_FOLDER + File.separator + fileName + ".bal");
    waitAndGetElementByXpath(driver, TestConstants.FILE_OPEN_POPUP_LOCATION_INPUT_XPATH)
            .sendKeys(BallerinaResourceLocation.getPath());
    //wait for the open button in the pop-up window
    waitAndGetElementByXpath(driver, TestConstants.FILE_OPEN_POPUP_LOCATION_OPEN_XPATH).click();
    //wait for the SVG element where the diagram is rendered
    WebElement domElement = waitAndGetElementByXpath(driver, TestConstants.SVG_XPATH);
    //Getting inner HTML of the SVG node
    String dom = TestUtils.preprocessDOMContent(domElement.getAttribute("innerHTML"));
    //TODO Add mechanism to generate DOM files
    //TestUtils.fileWriter(dom, fileName + "DOM.xml");
    URL DOMResourceLocation = BallerinaEditorUITest.class
            .getResource(TestConstants.DOM_RESOURCE_FOLDER + File.separator + fileName + "DOM.xml");
    //destroying browser instance
    driver.quit();/*from w w  w. j a va  2 s .  c o  m*/
    //checking inner content of the DOM element
    assertEquals("Rendered diagram of " + fileName + "is not equal to the expected diagram",
            TestUtils.fileReader(DOMResourceLocation.getPath()), dom);
}

From source file:TestEdreamsTest.java

@Test
public void testSomeMethod() {
    // TODO review the generated test code and remove the default call to fail.
    WebDriver driver = new FirefoxDriver();
    driver.get("www.google.es");
    //Do some actions
    //driver.quit();
}

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);

    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);//from www  .  java2s.c  om
    //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  2s  . 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:FormFiller.java

private static void pseudoMain(String[] args) throws IOException {
    if (args.length < 3 || args.length > 5)
        throw new IllegalArgumentException("Usage: lastName bankName deliveryDate [firstName] [print]\n"
                + "e.g. Hakim Ally 01/01/2016 OR Hakim Chase 1/1/2016 William print\n");

    if (args[args.length - 1].equals("print")) {
        print = true;/* www  .  j  a  v a 2 s .  c  o  m*/
    }

    WebDriver driver = getNewFirefoxDriver();

    driver.get("https://www.dealertrack.com/default1.aspx?RefreshBy=SM");

    HashMap dealerTrackData = new HashMap();

    try {

        WebElement username = driver.findElement(By.name("username"));
        username.sendKeys("whakim");
        WebElement pwd = driver.findElement(By.name("password"));
        pwd.sendKeys("keepbeepin23");
        driver.findElement(By.name("login")).submit();

        JavascriptExecutor jse = (JavascriptExecutor) driver;

        jse.executeScript("var script = document.createElement('script');\n"
                + "script.src = \"https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js\";\n"
                + "document.getElementsByTagName('head')[0].appendChild(script);");

        jse.executeScript("document.getElementById('iFrm').contentWindow.document.body."
                + "firstElementChild.contentDocument.getElementById('AppStatus').click()");

        int attempts = 0;
        while (attempts++ < 15) {
            Thread.sleep(500);
            try {
                jse.executeScript("document.getElementById('iFrm').contentWindow.document.body.childNodes[2]."
                        + "contentDocument.getElementById('txtSearchValue').value = '" + args[0] + "'");
                jse.executeScript("document.getElementById('iFrm').contentWindow.document.body.childNodes[2]."
                        + "contentDocument.getElementById('btnSearch').click();");
                break;
            } catch (WebDriverException e) {
                if (attempts >= 15)
                    e.printStackTrace();
            }
        }

        jse.executeScript("document.getElementById('iFrm').contentWindow.document.body.childNodes[2]."
                + "contentDocument.getElementById('btnSearch').click();");

        attempts = 0;
        String firstLenderName = null;
        int boxNum = -1;

        while (attempts++ < 10) {
            Thread.sleep(750);
            try {
                String boxName = (String) jse
                        .executeScript("return document.getElementById('iFrm').contentWindow.document."
                                + "body.childNodes[2].contentDocument.getElementById('applications_ctrl"
                                + ++boxNum + "_Tapplications_ctrl" + boxNum + "_TR').innerHTML");
                int comma = boxName.indexOf(',');

                if (comma == -1 || !(boxName.substring(0, comma).contains(args[0]))) {
                    boxNum--;
                    continue;
                }

                else if (args.length > 3 && !args[3].equals("print")
                        && !boxName.substring(comma, boxName.length()).contains(args[3]))
                    continue;

                long numApplications = (long) jse
                        .executeScript("return document.getElementById('iFrm').contentWindow.document."
                                + "body.childNodes[2].contentDocument.getElementsByClassName('lender_decisions')["
                                + boxNum + "]." + "childNodes[0].childElementCount");
                String firstLenderResult = (String) jse.executeScript("return document.getElementById('iFrm')."
                        + "contentWindow.document.body.childNodes[2].contentDocument.getElementsByClassName"
                        + "('lender_decisions')[" + boxNum + "].childNodes[0].childNodes[0].className");

                firstLenderName = (String) jse
                        .executeScript("return document.getElementById('iFrm').contentWindow."
                                + "document.body.childNodes[2].contentDocument.getElementsByClassName('lender_decisions')["
                                + boxNum + "]." + "childNodes[0].childNodes[0].childNodes[0].innerHTML");

                if (!firstLenderName.equals(args[1]) && numApplications == 1)
                    continue;

                String secondLenderResult = null;

                if (numApplications > 1) {
                    secondLenderResult = (String) jse.executeScript("return document.getElementById('iFrm')."
                            + "contentWindow.document.body.childNodes[2].contentDocument.getElementsByClassName"
                            + "('lender_decisions')[" + boxNum + "].childNodes[0].childNodes[1].className");
                }

                if (firstLenderResult.contains("declined")
                        && ((numApplications > 1) ? secondLenderResult.contains("declined")
                                : secondLenderResult == null))
                    continue;

                break;

            } catch (WebDriverException e) {
                boxNum--;
                if (attempts >= 10)
                    e.printStackTrace();
            }
        }

        attempts = 0;
        String apr = null;

        if (args[1].equals("Chase")) {

            if (firstLenderName.equals("Chase"))
                jse.executeScript(
                        "document.getElementById('iFrm').contentWindow.document.body.childNodes[2].contentDocument."
                                + "getElementsByClassName('lender_decisions')[" + boxNum
                                + "].childNodes[0].childNodes[0].childNodes[0].click()");

            else
                jse.executeScript(
                        "document.getElementById('iFrm').contentWindow.document.body.childNodes[2].contentDocument."
                                + "getElementsByClassName('lender_decisions')[" + boxNum
                                + "].childNodes[0].childNodes[1].childNodes[0].click()");

            // APR
            while (attempts++ < 10) {
                Thread.sleep(1500);
                try {
                    apr = (String) jse
                            .executeScript("return document.getElementById('iFrm').contentWindow.document."
                                    + "body.childNodes[2].contentDocument.getElementById('appDetails').contentDocument."
                                    + "getElementById('divHtml').childNodes[1].childNodes[1].childNodes[4].childNodes[1]."
                                    + "childNodes[5].firstElementChild.childNodes[0].childNodes[3].childNodes[3].childNodes[1]."
                                    + "childNodes[10].childNodes[3].childNodes[0].nodeValue");
                    break;
                } catch (WebDriverException e) {
                    if (attempts >= 10)
                        e.printStackTrace();
                }
            }

            dealerTrackData.put("Text201", "JPMorgan Chase Bk");
            dealerTrackData.put("fullBankName", "JPMorgan Chase Bk\nPO Box 901098\nFort Worth, TX 76101-2098");

        }

        else if (args[1].equals("Ally")) {

            if (firstLenderName.equals("Ally"))
                jse.executeScript(
                        "document.getElementById('iFrm').contentWindow.document.body.childNodes[2].contentDocument."
                                + "getElementsByClassName('lender_decisions')[" + boxNum
                                + "].childNodes[0].childNodes[0].childNodes[0].click()");

            else
                jse.executeScript(
                        "document.getElementById('iFrm').contentWindow.document.body.childNodes[2].contentDocument."
                                + "getElementsByClassName('lender_decisions')[" + boxNum
                                + "].childNodes[0].childNodes[1].childNodes[0].click()");

            // APR
            while (attempts++ < 10) {
                Thread.sleep(1500);
                try {
                    apr = (String) jse
                            .executeScript("return document.getElementById('iFrm').contentWindow.document."
                                    + "body.childNodes[2].contentDocument.getElementById('appDetails').contentDocument."
                                    + "getElementById('divHtml').childNodes[1].childNodes[1].childNodes[4].childNodes[1].childNodes[3]."
                                    + "childNodes[1].childNodes[2].childNodes[1].childNodes[2].childNodes[3].childNodes[1]."
                                    + "lastElementChild.childNodes[3].childNodes[0].data");
                    break;
                } catch (WebDriverException e) {
                    if (attempts >= 10)
                        e.printStackTrace();
                }

            }

            // Lienholder Name
            String lienName = null;
            attempts = 0;

            for (int i = 6; lienName == null
                    || !(lienName.contains(";") && lienName.contains("Ally")); i += 2, attempts++) {
                try {
                    lienName = tryAllyBox(jse, i);
                } catch (WebDriverException e) {
                    if (attempts >= 10)
                        e.printStackTrace();
                    Thread.sleep(50);
                }
            }

            dealerTrackData.put("Text201", lienName.substring(1, lienName.indexOf(";")));

            dealerTrackData.put("fullBankName", "Ally Bank\nP.O. Box 8128\nCockeysville, MD 21030");
        }

        else
            throw new IOException("Unsupported bank: " + args[1] + ". Choose Chase or Ally.");

        dealerTrackData.put("Text15", apr.substring(0, apr.length() - 2));

        Thread.sleep(1200);

        // Navigate to Application Info
        attempts = 0;
        while (attempts++ < 10) {
            Thread.sleep(50);
            try {
                jse.executeScript(
                        "document.getElementById('iFrm').contentWindow.document.body.childNodes[2].contentDocument."
                                + "getElementById('appDetails').contentDocument.getElementById('divBtn').childNodes[4].childNodes[1].click()");
                break;
            } catch (WebDriverException e) {
                if (attempts >= 10)
                    e.printStackTrace();
            }
        }

        attempts = 0;
        while (attempts++ < 15) {
            Thread.sleep(500);
            try {
                try {
                    jse.executeScript("document.getElementById('iFrm').contentWindow.document.body."
                            + "childNodes[2].contentDocument.getElementById('optAction_0').checked = true");
                    break;
                } catch (WebDriverException e) {
                    jse.executeScript("document.getElementById('iFrm').contentWindow.document.body."
                            + "childNodes[2].contentDocument.getElementById('optAction_copy_0').checked = true");
                    break;
                }
            } catch (WebDriverException e) {
                if (attempts >= 15) {
                    e.printStackTrace();
                }
            }
        }

        attempts = 0;
        while (attempts++ < 10) {
            Thread.sleep(250);
            try {
                jse.executeScript("document.getElementById('iFrm').contentWindow.document.body.childNodes[2]."
                        + "contentDocument.getElementById('btncontinue').click()");
                break;
            } catch (WebDriverException e) {
                if (attempts >= 10) {
                    e.printStackTrace();
                }
            }
        }

        // Sale ID
        attempts = 0;
        String sid = null;

        while (attempts++ < 20) {
            Thread.sleep(750);
            try {
                sid = (String) jse
                        .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                                + "childNodes[2].contentDocument.getElementById('app_stock_num').value");
                break;
            } catch (WebDriverException e) {
                if (attempts >= 20) {
                    e.printStackTrace();
                }
            }
        }

        dealerTrackData.put("Text3", sid);

        // Figure out what state the buyer is in
        dealerTrackData.put("buyerState", (String) jse.executeScript("return document.getElementById('iFrm')."
                + "contentWindow.document.body.childNodes[2].contentDocument.getElementById('app_state').value"));

        // Buyer Name and Address
        String firstName = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_first_name').value");

        String lastName = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_last_name').value");

        // Store applicant's name for PDF naming
        String fullName = firstName + " " + lastName;
        dealerTrackData.put("fullName", fullName);

        String address0 = (String) jse.executeScript("return ((document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_street_num').value).concat(' '))."
                + "concat(document.getElementById('iFrm').contentWindow.document.body.childNodes[2].contentDocument."
                + "getElementById('app_street_name').value)");

        String aptNum = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_apt_num').value");

        if (!aptNum.equals(""))
            address0 = address0 + " " + aptNum;

        String city = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_city').value");

        String state = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_state').value");

        String zipCode = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_zip_code').value");

        dealerTrackData.put("Text5", fullName + "\n" + address0 + "\n" + city + ", " + state + " " + zipCode);

        // Fill Name/Address Lines in Ally Credit App + Confirmation of Insurance, if applicable

        if (args[1].equals("Ally") || dealerTrackData.get("buyerState").equals("TX")) {
            dealerTrackData.put("Last Name (or trade name of business)", lastName);
            dealerTrackData.put("First", firstName);
            dealerTrackData.put("Present Address", address0);
            dealerTrackData.put("Zip Code", zipCode);
            dealerTrackData.put("City", city);
            dealerTrackData.put("State", state);
        }

        dealerTrackData.put("addressLine", address0 + ", " + city + ", " + state + " " + zipCode);

        boolean cosigner = false;

        // Co-Signer Name and Address (if applicable)
        try {
            String coAppFirstName = (String) jse
                    .executeScript("return document.getElementById('iFrm').contentWindow."
                            + "document.body.childNodes[2].contentDocument.getElementById('app_co_first_name').value");

            String coAppLastName = (String) jse
                    .executeScript("return document.getElementById('iFrm').contentWindow."
                            + "document.body.childNodes[2].contentDocument.getElementById('app_co_last_name').value");

            String coAppFullName = coAppFirstName + ' ' + coAppLastName;

            // Store Co-App Full Name (for TX Contract)
            dealerTrackData.put("coAppFullName", coAppFullName);

            String coAppAddress0 = (String) jse
                    .executeScript("return ((document.getElementById('iFrm').contentWindow."
                            + "document.body.childNodes[2].contentDocument.getElementById('app_co_street_num').value).concat(' '))."
                            + "concat(document.getElementById('iFrm').contentWindow.document.body.childNodes[2].contentDocument."
                            + "getElementById('app_co_street_name').value)");

            String coAppAptNum = (String) jse
                    .executeScript("return document.getElementById('iFrm').contentWindow."
                            + "document.body.childNodes[2].contentDocument.getElementById('app_co_apt_num').value");

            if (!coAppAptNum.equals(""))
                coAppAddress0 = coAppAddress0 + " " + coAppAptNum;

            String coAppCity = (String) jse
                    .executeScript("return document.getElementById('iFrm').contentWindow."
                            + "document.body.childNodes[2].contentDocument.getElementById('app_co_city').value");

            String coAppState = (String) jse
                    .executeScript("return document.getElementById('iFrm').contentWindow."
                            + "document.body.childNodes[2].contentDocument.getElementById('app_co_state').value");

            String coAppZipCode = (String) jse
                    .executeScript("return document.getElementById('iFrm').contentWindow."
                            + "document.body.childNodes[2].contentDocument.getElementById('app_co_zip_code').value");

            dealerTrackData.put("Text6", coAppFullName + "\n" + coAppAddress0 + "\n" + coAppCity + ", "
                    + coAppState + " " + coAppZipCode);

            if (args[1].equals("Ally") || dealerTrackData.get("buyerState").equals("TX")) {
                dealerTrackData.put("First2", coAppFirstName);
                dealerTrackData.put("Last Name (or trade nameof business)2", coAppLastName);
                dealerTrackData.put("Present Address2", coAppAddress0);
                dealerTrackData.put("Zip Code2", coAppZipCode);
                dealerTrackData.put("City2", coAppCity);
                dealerTrackData.put("State2", coAppState);
            }

            cosigner = true;

        } catch (WebDriverException e) {
            dealerTrackData.put("cosignerNullField", "N/A");
        }

        // Car Year
        String carYear = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementById('app_auto_yearList').value");
        dealerTrackData.put("Text9", carYear);

        // Car Make and Model
        String carMake = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_auto_makeList').value");

        String carModel = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_auto_modelList').value");

        dealerTrackData.put("Text10", carMake + ' ' + carModel);

        dealerTrackData.put("Make", carMake);
        dealerTrackData.put("Model", carModel);

        // Style/Trim
        String carStyleTrim = (String) jse.executeScript("return document.getElementById('iFrm').contentWindow."
                + "document.body.childNodes[2].contentDocument.getElementById('app_auto_trimList').value");
        dealerTrackData.put("StylefTrim", carStyleTrim);

        // VIN
        String vin = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementById('app_vin_num').value");
        dealerTrackData.put("Text12", vin);

        // Amount Financed
        if (args[1].equals("Chase"))
            recalculateChaseStructure(jse);

        String amountFinanced = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementsByName('app_est_amt_financed')[0].value");
        double amountFinancedDouble = Double.parseDouble(amountFinanced);
        String amountFinancedFormatted = moneyFormatter.format(amountFinancedDouble);
        dealerTrackData.put("Text17", amountFinancedFormatted);

        // Term
        String loanTerm = (jse
                .executeScript("return (document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementsByName('app_terms')[0].value - 1)")
                .toString());
        dealerTrackData.put("Number Payments 4", dealerTrackData.get("buyerState").equals("CA") ? loanTerm
                : Integer.toString(Integer.parseInt(loanTerm) + 1));

        // Meaty Loan Calculations
        double aprDouble = (Double.parseDouble((String) dealerTrackData.get("Text15")) / (Double) 100.);
        int loanTermInt = Integer.parseInt(loanTerm) + 1;

        double monthlyPayment = Double.parseDouble(moneyFormatter.format(amountFinancedDouble
                * (aprDouble / 12.) / (1. - Math.pow(1. + aprDouble / 12., -loanTermInt))));
        String roundMonthlyPayment = moneyFormatter.format(monthlyPayment);

        double totalOfPayments = monthlyPayment * loanTermInt;
        String roundTotalOfPayments = moneyFormatter.format(totalOfPayments);

        // Total of Payments
        dealerTrackData.put("Text18", roundTotalOfPayments);

        // Finance Charge (take care of down payment later)
        dealerTrackData.put("Text16", moneyFormatter.format(totalOfPayments - amountFinancedDouble));

        // Monthly Payments
        dealerTrackData.put("Text26", roundMonthlyPayment);
        dealerTrackData.put("Text31", roundMonthlyPayment);

        // First and Last Payment Date
        DateTimeFormatter ddFormat = DateTimeFormatter.ofPattern("M/d/yyyy");
        LocalDate dd = LocalDate.parse(args[2], ddFormat);
        int plusDays = (args[1].equals("Chase")) ? 45 : 30;

        LocalDate firstPayment = dd.plusDays(plusDays);
        LocalDate lastPayment = firstPayment.plusMonths(loanTermInt - 1);

        String firstPaymentFormatted = firstPayment.format(ddFormat);
        String lastPaymentFormatted = lastPayment.format(ddFormat);

        dealerTrackData.put("Text27", firstPaymentFormatted);
        dealerTrackData.put("Text32", lastPaymentFormatted);

        // Car Base Price
        String carBasePrice = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementsByName('app_price')[0].value");
        double carBasePriceDouble = Double.parseDouble(carBasePrice);
        String carBasePriceFormatted = moneyFormatter.format(carBasePriceDouble);

        dealerTrackData.put("Text33", carBasePriceFormatted);
        dealerTrackData.put("Text34", carBasePriceFormatted);

        // Sales Tax
        String carTaxes = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementsByName('app_sales_tax')[0].value");
        double carTaxesDouble = Double.parseDouble(carTaxes);
        String carTaxesFormatted = moneyFormatter.format(carTaxesDouble);

        dealerTrackData.put("Text49", carTaxesFormatted);

        // Extended Peace of Mind
        String serviceContract = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementsByName('app_warranty')[0].value");
        Double serviceContractDouble = 0.;

        if (!serviceContract.equals("")) {
            serviceContractDouble = Double.parseDouble(serviceContract);

            dealerTrackData.put("Text51", moneyFormatter.format(serviceContractDouble));
            // For California Contract
            dealerTrackData.put("Text94", "Beepi Peace of Mind");
            dealerTrackData.put("7/13_1LCompany", "Beepi Peace of Mind");
            // For Arizona or Texas Contract
            dealerTrackData.put("Beepi", "Beepi");
            dealerTrackData.put("na5", "Extended Peace of Mind");

        }

        // Documentary Service Fees
        String documentFee = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementsByName('app_other_finance_fees')[0].value");
        Double documentFeeDouble = 0.;

        if (!documentFee.equals("")) {
            documentFeeDouble = Double.parseDouble(documentFee);
            dealerTrackData.put("Text42", moneyFormatter.format(documentFeeDouble));
        }

        // Registration Fees
        String regFees = (String) jse
                .executeScript("return document.getElementById('iFrm').contentWindow.document.body."
                        + "childNodes[2].contentDocument.getElementsByName('app_ttl')[0].value");
        double regFeesDouble = Double.parseDouble(regFees);
        String regFeesFormatted = moneyFormatter.format(regFeesDouble);

        dealerTrackData.put("Text62", regFeesFormatted);
        dealerTrackData.put("Text65", regFeesFormatted);

        // Calculate Contract Based on State
        switch ((String) dealerTrackData.get("buyerState")) {
        case "CA":
            californiaContract(args, jse, dealerTrackData, carBasePriceDouble, carTaxesDouble,
                    serviceContractDouble, regFeesDouble, documentFeeDouble, totalOfPayments);
            break;
        case "AZ":
        case "TX":
        case "WA":
            arizonaTexasWashingtonContract(args, jse, dealerTrackData, carBasePriceDouble, carTaxesDouble,
                    serviceContractDouble, regFeesDouble, documentFeeDouble, totalOfPayments);
            break;
        }

        // Amount Financed
        dealerTrackData.put("Text77", amountFinancedFormatted);

        // Delivery Date (Signatures)
        String ddFormatted = dd.format(ddFormat);

        dealerTrackData.put("Text159", ddFormatted);
        dealerTrackData.put("Text165", ddFormatted);

        if (cosigner)
            dealerTrackData.put("Text160", ddFormatted);

        // Populate Credit Applications
        if (args[1].equals("Ally"))
            getAllyCreditInfo(jse, dealerTrackData, cosigner);
        else
            getChaseCreditInfo(jse, dealerTrackData, driver);

    } catch (Exception e) {
        e.printStackTrace();
    }

    driver.quit();

    String contractDir = "DO NOT EDIT - AutoFill Contracts/";

    try {

        if (args[1].equals("Ally")) {
            outputDir = makeOutputDir(dealerTrackData);
            fillPdf(dealerTrackData, contractDir + "Blank Ally Credit Application.pdf", outputDir,
                    "Ally Credit Application");
            fillPdf(dealerTrackData, contractDir + "Blank Ally Odometer Disclosure.pdf", outputDir,
                    "Ally Odometer Disclosure");
            fillPdf(dealerTrackData, contractDir + "Blank Ally Insurance Form.pdf", outputDir,
                    "Ally Insurance Form");
            fillPdf(dealerTrackData, contractDir + "Ally Title Guarantee.pdf", outputDir, "Guarantee of Title");
        }

        else {
            fillPdf(dealerTrackData, contractDir + "Blank Agreement to Furnish Insurance.pdf", outputDir,
                    "Chase Insurance Form");
            fillPdf(dealerTrackData, contractDir + "Chase Title Guarantee.pdf", outputDir,
                    "Guarantee of Title");
        }

        switch ((String) dealerTrackData.get("buyerState")) {
        case "CA":
            fillPdf(dealerTrackData, contractDir + "Blank Purchase Contract-N-A'd out.pdf", outputDir,
                    "Purchase Contract");
            break;
        case "AZ":
            fillPdf(dealerTrackData, contractDir + "Blank AZ Purchase Contract-N-A'd out.pdf", outputDir,
                    "Purchase Contract");
            break;
        case "TX":
            fillPdf(dealerTrackData, contractDir + "Blank TX Purchase Contract-N-A'd out.pdf", outputDir,
                    "Purchase Contract");
            break;
        case "WA":
            fillPdf(dealerTrackData, contractDir + "Blank WA Purchase Contract-N-A'd out.pdf", outputDir,
                    "Purchase Contract");
            break;
        }

    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:IntegracaoIT.java

@Test
public void testSimple() throws Exception {
    // Create a new instance of the Firefox driver
    // Notice that the remainder of the code relies on the interface, 
    // not the implementation.
    WebDriver driver = new FirefoxDriver();

    // And now use this to visit NetBeans
    driver.get("http://www.netbeans.org");
    // Alternatively the same thing can be done like this
    // driver.navigate().to("http://www.netbeans.org");

    // Check the title of the page
    // Wait for the page to load, timeout after 10 seconds
    (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
        @Override//from w  w  w . j  a  v a2 s .c  om
        public Boolean apply(WebDriver d) {
            return d.getTitle().contains("NetBeans");
        }
    });

    //Close the browser
    driver.quit();
}

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 {//from   w  ww  .j  ava 2s .  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:facets_testing.java

public void wp_login() {
    WebDriver driver = new ChromeDriver();
    try {/*from   ww w. j  av a2 s  .  com*/
        driver.get(wordpress_url);
        driver.findElement(By.id("user_login")).sendKeys(username);
        driver.findElement(By.id("user_pass")).sendKeys(password);
        driver.findElement(By.id("wp-submit")).click();
    } catch (Exception e) {
        System.out.println("Exception produced when logging into wp-admin. Error is: " + e);
    }
}

From source file:UnitTest1.java

public UnitTest1() throws InterruptedException {

    // Create a new instance of the Firefox driver

    String exePath = "C:\\Unit Testing\\Drivers\\chromedriver.exe";
    System.setProperty("webdriver.chrome.driver", exePath);
    WebDriver driver = new ChromeDriver();

    //Launch the Online Store Website
    driver.get("http://www.store.demoqa.com");

    // Print a Log In message to the screen
    System.out.println("Successfully opened the website www.Store.Demoqa.com");

    //Wait for 5 Sec
    Thread.sleep(5);/*  w w w  .  j  av a2  s.co m*/

    // Close the driver
    driver.quit();

}