Example usage for org.openqa.selenium Keys ENTER

List of usage examples for org.openqa.selenium Keys ENTER

Introduction

In this page you can find the example usage for org.openqa.selenium Keys ENTER.

Prototype

Keys ENTER

To view the source code for org.openqa.selenium Keys ENTER.

Click Source Link

Usage

From source file:scormADL2004.java

License:Open Source License

@Test
/**/*www  .  jav a 2 s .c om*/
 * navigate inside ADL SCORM 2004 Test Course to check for packages uploaded.
 */
public void loginCourse() throws IOException {
    driver.findElement(By.linkText("SCORM 2004 ADL test course")).sendKeys(Keys.ENTER);
    wait.until(presenceOfElementLocated(By.id("username")));
    driver.findElement(By.id("username")).clear();
    driver.findElement(By.id("password")).clear();
    //Login username password as specified
    driver.findElement(By.id("username")).sendKeys(username1);
    driver.findElement(By.id("password")).sendKeys(password1);
    loginSession = 1;
    driver.findElement(By.id("loginbtn")).click();
    fetchAllContent();
}

From source file:scormADL2004.java

License:Open Source License

public void switchLoginSession(int toLogin) {
    // To be safe and avoid Selenium Native click element, using submit wherever possible, to be fixed in 2.5.0
    WebElement element;//  www  . ja  v a 2  s  . co m
    driver.switchTo().window("moodleWindow");
    // Check if already logged in
    if (!isElementPresent(By.linkText("Login"))) {
        //driver.findElement(By.linkText("Logout")).click();
        // Workaround for Selenium bug - 1020, to be fixed in 2.5.0
        driver.findElement(By.linkText("Logout")).sendKeys(Keys.ENTER);
        wait.until(presenceOfElementLocated(By.linkText("SCORM 2004 ADL test course")));
        driver.findElement(By.linkText("SCORM 2004 ADL test course")).click();
    }
    if (toLogin != 2) {
        wait.until(presenceOfElementLocated(By.id("username")));
        driver.findElement(By.id("username")).clear();
        element = driver.findElement(By.id("password"));
        element.clear();
        driver.findElement(By.id("username")).sendKeys(username1);
        element.sendKeys(password1);
        loginSession = 1;
    } else {
        wait.until(presenceOfElementLocated(By.id("username")));
        driver.findElement(By.id("username")).clear();
        element = driver.findElement(By.id("password"));
        driver.findElement(By.id("username")).sendKeys(username2);
        element.sendKeys(password2);
        loginSession = 2;
    }
    element.submit();
}

From source file:scormADL2004.java

License:Open Source License

/**
 * Handle / Launch SCO's/*from  w  w w  . j a v  a2 s. c o  m*/
 */
public void defaultSCOHandler() {
    // Handle Selenium IE Bug by explicit wait
    int scoCount = fetchAllSCO();
    int scoNo = 1;
    String userInstruction, activityName = null;
    // Not infinite loop, testing based on TestSuite Instrcutions
    while (scoCount > 0) {
        //First Activity does not need to be launched, launch after first
        driver.switchTo().window("moodleWindow");
        driver.switchTo().frame("scorm_object");
        wait.until(presenceOfElementLocated(By.id("teststatus")));
        //wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'progress...')]")));
        // Allow loading time, specially for UI tests
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }
        userInstruction = readUserInstructions();
        if (userInstruction.contains("LMS User Interface")) {
            answerDefaultUI(scoNo);
            driver.switchTo().window("moodleWindow");
        } else {
            // Print only for 1st Activity.
            if (scoNo == 1) {
                System.out.println("Testing Activity. Please Wait... ");
            }
            driver.switchTo().window("moodleWindow");
            driver.switchTo().frame("scorm_object");
            //Check only for "Completed." as some packages contain extra spaces
            wait.until(presenceOfElementLocated(By.xpath("//div[contains(.,'Completed.')]")));
            System.out.println("Testing of Activity Completed.");
            driver.switchTo().window("moodleWindow");
        }
        // Read instructions to launch new activity
        // First Activity does not need to be launched.

        userInstruction = readUserInstructions();
        if (!userInstruction.contains("relaunch")
                && !(userInstruction.contains("please exit the package/course"))
                && userInstruction.contains("launch")) {
            activityName = userInstruction.substring((userInstruction.lastIndexOf("nch ") + 4),
                    userInstruction.lastIndexOf("."));
            activityName = activityName.trim();
            driver.switchTo().window("moodleWindow");
            driver.findElement(By.xpath("//span[contains(.,'" + activityName + "')]")).click();
            System.out.println("Testing Activity " + activityName + ". Please Wait... ");
            // Allow loading time of new Activity
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } else if (userInstruction.contains("trigger a Continue Navigation Event")) {
            driver.switchTo().window("moodleWindow");
            driver.findElement(By.id("nav_next-button")).sendKeys(Keys.ENTER);
        } else if (userInstruction.contains("trigger a Previous Navigation Event")) {
            driver.switchTo().window("moodleWindow");
            driver.findElement(By.id("nav_prev-button")).sendKeys(Keys.ENTER);
        } else if (userInstruction.contains("relaunch")) {
            driver.switchTo().window("moodleWindow");
            driver.findElement(By.linkText("ADL 2004")).sendKeys(Keys.ENTER);
            launchTestPackage(userInstruction.substring((userInstruction.lastIndexOf("age ") + 4),
                    (userInstruction.lastIndexOf("to") - 1)));
        } else if (userInstruction.contains("please exit the package/course")) {
            if (userInstruction.contains("launch")) {
                driver.switchTo().window("moodleWindow");
                driver.findElement(By.linkText("ADL 2004")).sendKeys(Keys.ENTER);
                launchTestPackage(userInstruction.substring((userInstruction.lastIndexOf("age ") + 4),
                        userInstruction.lastIndexOf(".")));
            } else {
                System.out.println("Testing of Package Completed.");
                break;
            }
        } else if (userInstruction.isEmpty()) {
            // Launch last activity again.
            driver.switchTo().window("moodleWindow");
            driver.findElement(By.xpath("//span[contains(.,'" + activityName + "')]")).click();
        }
        scoNo++;
    }
    // Old way of handling tests.
    /*for (int i = 1; i <= scoCount; i++) {
       //First Activity does not need to be launched.
       if(i != 1) {
    driver.findElement(By.id("ygtvlabelel"+i)).click();
       }
       driver.switchTo().frame("scorm_object");
       wait.until(presenceOfElementLocated(By.id("teststatus")));
       wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'progress...')]")));
       boolean uiTestPresent = isInstructionForUIPresent();
       if (uiTestPresent) {
    answerDefaultUI(i);
       } else {
    System.out.println("Testing Activity "+i+". Please Wait... ");
    //Check only for "Completed." as some packages contain extra spaces
    wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'Completed.')]")));
    System.out.println("Testing of Activity "+i+" Completed.");
    driver.switchTo().window("moodleWindow");
       }
    }
    // Some test packages need to launch 
    System.out.println("Testing Completed.");
    driver.switchTo().window("");
    driver.switchTo().frame("controls");
    wait.until(presenceOfElementLocated(By.id("continue")));
    driver.findElement(By.id("continue")).click(); */
}

From source file:scormADL2004.java

License:Open Source License

/**
 * Select All valid tests to perform in ADL 2004 Test Suite
 * @param testsToExecute/*from  ww  w  .  j a v  a  2  s .c om*/
 */
public void initialiseTestSuite(String[] testsToExecute) {
    driver.switchTo().window("");
    driver.switchTo().frame("instructions");
    Select multipleTestsSelect = new Select(driver.findElement(By.id("possible")));
    multipleTestsSelect.deselectAll();
    for (int i = 0; i < testsToExecute.length; i++) {
        multipleTestsSelect.selectByVisibleText(testsToExecute[i]);
    }
    // Workaround for Selenium bug - 1020, to be fixed in 2.5.0
    driver.findElement(By.id("add")).sendKeys(Keys.ENTER);
    driver.switchTo().window("");
    driver.switchTo().frame("controls");
    driver.findElement(By.id("continue")).click();
    try {
        driver.switchTo().alert().accept();
    } catch (NoAlertPresentException ex) {
    }

}

From source file:scormADL2004.java

License:Open Source License

public void launchTestPackage(String testPackageName) {
    // Check to see which user should launch the package.
    checkLoginSession();/*www.  java2  s .  co  m*/
    driver.switchTo().window("moodleWindow");
    wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'Recent activity')]")));
    if (testPackageName.equalsIgnoreCase("DDM")) {
        driver.findElement(By.partialLinkText(testPackageName + "a SCORM package")).sendKeys(Keys.ENTER);
    } else {
        driver.findElement(By.partialLinkText(testPackageName + " SCORM package")).sendKeys(Keys.ENTER);
    }
    // Workaround for WebDriver bug, Seleniu, IE.
    wait.until(presenceOfElementLocated(By.id("page-footer")));
    // Refresh Driver to crawl page again.
    driver.switchTo().window("moodleWindow");
    if (isElementPresent(By.id("n"))) {
        WebElement element = driver.findElement(By.id("n"));
        element.click();
        element.submit();
        //driver.findElement(By.xpath("//input[@value='Enter']")).click();
    }
}

From source file:scormADL2004.java

License:Open Source License

/**
 * Handle / Launches test packages in order they are specified.
 * @param String[] testsToExecute/*www. ja va 2 s .  c o  m*/
 */
public void testsHandler(String[] testsToExecute) {
    if (testsToExecute[0] == "") {
        // No tests uploaded
        throw new NullPointerException("No specified tests found or uploaded.");
    }
    initialiseTestSuite(testsToExecute);
    driver.switchTo().window("");
    driver.switchTo().frame("currentInstructions");
    wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'Login to the LMS')]")));
    // Check if current user login is the required user logged in
    checkLoginSession();
    driver.switchTo().window("moodleWindow");
    // Wait till Page completely loads - Selenium Bug
    wait.until(presenceOfElementLocated(By.xpath("//*[contains(.,'Recent activity)]")));
    for (int i = 0; i < testsToExecute.length; i++) {
        System.out.println("Testing ADL SCORM 2004 " + testsToExecute[i] + " package...");
        launchTestPackage(testsToExecute[i]);
        //switch cannot compare string
        // TODO add handle for CM-01 Test
        if (testsToExecute[i].equalsIgnoreCase("CM-01")) {
            handleCM01Test();
        }
        // default case
        else {
            defaultSCOHandler();
        }
        driver.switchTo().window("moodleWindow");
        driver.findElement(By.linkText("Exit activity")).click();
        wait.until(presenceOfElementLocated(By.partialLinkText(testsToExecute[i] + " SCORM package")));
        driver.switchTo().window("");
        driver.switchTo().frame("controls");
        wait.until(presenceOfElementLocated(By.id("continue")));
        driver.findElement(By.id("continue")).sendKeys(Keys.ENTER);
    }
    driver.findElement(By.linkText("Logout")).click();
    System.out.println("Tested All Packages. The Script will now exit.");
}

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  . ja  v a  2 s.c  om
        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 {/*from   w w  w  .j ava  2 s  .com*/
        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:businesscomponents.ReportcomparisonComponents.java

public void storePreReportValues() throws IOException, InterruptedException {

    String Report = dataTable.getData("General_Data", "ReportName");
    oldTab = driver.getWindowHandle();//from w w  w.  ja v  a2s. com
    Thread.sleep(1000);
    newTab = new ArrayList<String>(driver.getWindowHandles());
    newTab.remove(oldTab);
    if (reportIterator > 1) {
        oldtab1 = driver.getWindowHandle();
        newTab.remove(oldtab1);
    }
    int s3 = newTab.size();
    if (s3 > 1) {
        driver.switchTo().window(newTab.get(s3 - 1));
        System.out.println("Window name in second Iteration is : " + driver.getTitle());
    } else {
        driver.switchTo().window(newTab.get(0));
    }
    Thread.sleep(1000);
    WebElement frame3 = driver.findElement(By.id("reportframe"));
    driver.switchTo().frame(frame3);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String strPageVal = "";
    //Conditions for Different Reports

    if (Report.contains("MRF412")) {
        strPageVal = mObj.getPageNoMRF412().getText();
    } else if (Report.contains("MRF417")) {
        strPageVal = mObj.getPageNoMRF417().getText();
    } else if (Report.contains("MRF208")) {
        strPageVal = mObj.getPageNoMRF208().getText();
    } else if (Report.contains("MRO202")) {
        strPageVal = mObj.getPageNoMRF203n203().getText();
    } else if (Report.contains("MRO203"))

    {
        strPageVal = mObj.getPageNoMRF203n203().getText();
    }
    String noOfPages = driver
            .findElement(By.xpath("//input[@name='editThis']/parent::td/following-sibling::td/font")).getText()
            .trim();
    noOfPages = noOfPages.substring(3, noOfPages.length());
    int intPostPageNo1;
    intPostPageNo1 = Integer.parseInt(noOfPages);
    strPageVal = noOfPages;

    ArrayList<String> strPartnerName1 = new ArrayList<String>();
    int intVarIncement = 0;
    int TotalPages = Integer.parseInt(strPageVal);
    String strPageTitle = mObj.getPageTitle().getText();
    //Condition for sampling 
    if (TotalPages > 50) {
        samplingAppl = 1;
        pagenoPreReport = TotalPages;
        int LastPage = TotalPages;
        //for first page
        if (strPageTitle.contains("MultiUserTest License")) {
            report.updateTestLog("Verify Page Title", "Page Title Verification is successful for page 1",
                    Status.PASS);
            strPartnerName1 = mObj.getAllValuesFromPage1();
            strSamplingPageNumber.add("1");

            page.add(strPartnerName1);

        }

        else {
            report.updateTestLog("Verify Page Title", "Page Title Verification failed for Page 1", Status.FAIL);
        }
        //for last page
        driver.switchTo().window(newTab.get(0));
        driver.switchTo().frame("toolbarframe");
        String lspage = Integer.toString(LastPage);
        mObj.getEditPageToolbar().clear();
        mObj.getEditPageToolbar().sendKeys(lspage);

        mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
        report.updateTestLog("Enter Last page", "Last Page is entered in Edit box", Status.DONE);
        Thread.sleep(1500);
        driver.switchTo().window(newTab.get(0));
        driver.switchTo().frame(frame3);
        strPageTitle = mObj.getPageTitle().getText();
        if (strPageTitle.contains("MultiUserTest License")) {
            report.updateTestLog("Verify Page Title", "Page Title Verification is successful for Last Page",
                    Status.PASS);
            strPartnerName1 = mObj.getAllValuesFromPage1();
            strSamplingPageNumber.add(strPageVal);
            page.add(strPartnerName1);
        }

        else {
            report.updateTestLog("Verify Page Title", "Page Title Verification failed for Last Page",
                    Status.FAIL);
        }

        // For Other Pages
        if (s3 > 1) {
            driver.switchTo().window(newTab.get(s3 - 1));
        } else {
            driver.switchTo().window(newTab.get(0));

        }
        driver.switchTo().frame("toolbarframe");
        mObj.getEditPageToolbar().clear();
        mObj.getEditPageToolbar().sendKeys("2");
        mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
        report.updateTestLog("Enter Second page", "Second Page is entered in Edit box", Status.DONE);
        Thread.sleep(1500);
        if (s3 > 1) {
            driver.switchTo().window(newTab.get(s3 - 1));
        } else {
            driver.switchTo().window(newTab.get(0));

        }
        driver.switchTo().frame(frame3);
        for (int Pageiter1 = 1; Pageiter1 < (TotalPages - 1); Pageiter1++) {

            strPageTitle = mObj.getPageTitle().getText();
            intVarIncement = (int) Math.pow(2, Pageiter1);
            if (strPageTitle.contains("MultiUserTest License")) {
                report.updateTestLog("Verify Page Title",
                        "Page Title Verification is successful for page " + intVarIncement, Status.PASS);
                strPartnerName1 = mObj.getAllValuesFromPage1();
                strSamplingPageNumber.add(Integer.toString(intVarIncement));
                page.add(strPartnerName1);
            } else {
                report.updateTestLog("Verify Page Title",
                        "Page Title Verification failed for Page " + intVarIncement, Status.FAIL);
            }

            if (s3 > 1) {
                driver.switchTo().window(newTab.get(s3 - 1));
            } else {
                driver.switchTo().window(newTab.get(0));

            }
            driver.switchTo().frame("toolbarframe");
            Thread.sleep(1000);
            if (intVarIncement > TotalPages) {
                break;
            } else {
                mObj.getEditPageToolbar().clear();
                mObj.getEditPageToolbar().sendKeys(Integer.toString(intVarIncement));
                mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
                synchronized (driver) {
                    driver.wait(1000);
                }
                if (s3 > 1) {
                    driver.switchTo().window(newTab.get(s3 - 1));
                } else {
                    driver.switchTo().window(newTab.get(0));
                }
                WebElement frame3_upd = driver.findElement(By.id("reportframe"));
                driver.switchTo().frame(frame3_upd);
            }

        }
        pages.add(page);
    }

    else {
        pagenoPreReport = TotalPages;
        // Loop for storing values page by page
        for (int Pageiter = 0; Pageiter < TotalPages; Pageiter++) {
            String strPageSource = driver.getPageSource();
            CommonData.strPageSource = strPageSource;
            strPageTitle = mObj.getPageTitle().getText();
            CommonData.strPageTitle = strPageTitle;
            if (strPageTitle.contains("MultiUserTest License")) {
                report.updateTestLog("Verify Page Title",
                        "Page Title Verification is successful for page" + (Pageiter + 1), Status.PASS);
                String strPartnerNameList1;
                CommonData.strPageNumber = strPageVal;
                strPartnerName1 = mObj.getAllValuesFromPage1();
                page.add(strPartnerName1);
            }

            else {
                report.updateTestLog("Verify Page Title", "Page Title Verification", Status.FAIL);
            }
            if (s3 > 1) {
                driver.switchTo().window(newTab.get(s3 - 1));
            } else {
                driver.switchTo().window(newTab.get(0));
            }
            driver.switchTo().frame("toolbarframe");

            mObj.getNextLink().click();

            synchronized (driver) {
                driver.wait(1000);
            }
            if (s3 > 1) {
                driver.switchTo().window(newTab.get(s3 - 1));
            } else {
                driver.switchTo().window(newTab.get(0));
            }
            WebElement frame3_upd = driver.findElement(By.id("reportframe"));
            driver.switchTo().frame(frame3_upd);
        }
        pages.add(page);
    }
    report.updateTestLog("Storing Data", "Data has been stored for Pre report", Status.DONE);
    //End code for Pre Report
    driver.switchTo().defaultContent();
    driver.close();
    driver.switchTo().window(oldTab);
}

From source file:businesscomponents.ReportcomparisonComponents.java

public void getPostReportValues() throws InterruptedException {
    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
    WebElement folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
    driver.switchTo().frame(folderFrame);
    String strPostFolderName = dataTable.getData("General_Data", "PostReportFolderName");
    driver.findElement(By.xpath("//a[contains(@href,'" + strPostFolderName + "')]")).click();
    driver.switchTo().defaultContent();/* w w w .  ja v a  2 s  .  c  o m*/
    String strPostSubFolderName = dataTable.getData("General_Data", "PostReportSubFolderName");
    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
    driver.switchTo().frame(folderFrame);
    driver.findElement(By.xpath("//a[contains(@href,'" + strPostSubFolderName + "')]")).click();
    driver.switchTo().defaultContent();
    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
    WebElement documentsFrame = driver.findElement(By.xpath("//frame[@name='main']"));
    driver.switchTo().frame(documentsFrame);
    int ReportVersion = mObj.getcountPostReportVersion().size();
    mObj.getcountPostReportVersion().get(ReportVersion - 1).click();
    driver.switchTo().defaultContent();
    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
    driver.switchTo().frame(documentsFrame);
    driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
    String noOfPages = driver
            .findElement(By.xpath("//input[@name='editThis']/parent::td/following-sibling::td/font")).getText()
            .trim();
    noOfPages = noOfPages.substring(3, noOfPages.length());
    int intPostPageNo1;
    intPostPageNo1 = Integer.parseInt(noOfPages);
    intPostPageNo = intPostPageNo1;
    ArrayList<String> currentReportValues = new ArrayList<String>();
    ArrayList<String> PostReportValues = new ArrayList<String>();
    driver.switchTo().defaultContent();
    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
    driver.switchTo().frame(driver.findElement(By.name("main")));
    driver.switchTo().frame(driver.findElement(By.id("reportframe")));
    if (intPostPageNo > 50) {
        int LastPostPage = intPostPageNo;
        //for first page
        PostReportValues = mObj.getAllValuesFromPage2();
        postPage.add(PostReportValues);
        //for last page
        driver.switchTo().defaultContent();
        driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
        driver.switchTo().frame(driver.findElement(By.name("main")));
        driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
        driver.findElement(By.name("editThis")).clear();
        driver.findElement(By.name("editThis")).sendKeys(Integer.toString(LastPostPage));
        driver.findElement(By.name("editThis")).sendKeys(Keys.ENTER);
        driver.switchTo().defaultContent();
        driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
        driver.switchTo().frame(driver.findElement(By.name("main")));
        driver.switchTo().frame(driver.findElement(By.id("reportframe")));
        PostReportValues = mObj.getAllValuesFromPage2();
        postPage.add(PostReportValues);
        driver.switchTo().defaultContent();
        driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
        driver.switchTo().frame(driver.findElement(By.name("main")));
        driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
        mObj.getEditPageToolbar().clear();
        mObj.getEditPageToolbar().sendKeys("2");
        mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
        driver.switchTo().defaultContent();
        driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
        driver.switchTo().frame(driver.findElement(By.name("main")));
        driver.switchTo().frame(driver.findElement(By.id("reportframe")));
        for (int PostPageiter1 = 1; PostPageiter1 < (LastPostPage - 1); PostPageiter1++) {
            int intPostVarIncement = (int) Math.pow(2, PostPageiter1);
            PostReportValues = mObj.getAllValuesFromPage2();
            postPage.add(PostReportValues);
            driver.switchTo().defaultContent();
            driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
            driver.switchTo().frame(driver.findElement(By.name("main")));
            driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
            Thread.sleep(1000);
            if (intPostVarIncement > LastPostPage) {
                break;
            } else {
                mObj.getEditPageToolbar().clear();
                mObj.getEditPageToolbar().sendKeys(Integer.toString(intPostVarIncement));
                mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
                synchronized (driver) {
                    driver.wait(1000);
                }
                driver.switchTo().defaultContent();
                driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                driver.switchTo().frame(driver.findElement(By.name("main")));
                driver.switchTo().frame(driver.findElement(By.id("reportframe")));
            }
        }
        Postpages.add(postPage);
    } else {
        for (int i = 0; i < intPostPageNo; i++) {

            driver.switchTo().defaultContent();
            driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
            driver.switchTo().frame(driver.findElement(By.name("main")));
            driver.switchTo().frame(driver.findElement(By.id("reportframe")));
            currentReportValues = mObj.getAllValuesFromPage2();
            driver.switchTo().defaultContent();
            driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
            driver.switchTo().frame(driver.findElement(By.name("main")));
            driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
            driver.findElement(By.name("button4")).click();
            driver.switchTo().defaultContent();
            postPage.add(currentReportValues);
        }

        Postpages.add(postPage);
    }
}