Example usage for org.openqa.selenium By xpath

List of usage examples for org.openqa.selenium By xpath

Introduction

In this page you can find the example usage for org.openqa.selenium By xpath.

Prototype

public static By xpath(String xpathExpression) 

Source Link

Usage

From source file:businesscomponents.ReportcomparisonComponents1.java

public void completeReportComparisonNew() throws Exception {
    Thread.sleep(1000);/*from   w w  w  .j av a 2s .  c  o  m*/
    int flagPrepg, flagPostPg;
    flagPrepg = 0;
    flagPostPg = 0;
    String TC_ID = dataTable.getData("General_Data", "TC_ID");
    String PreURL = dataTable.getData("General_Data", "PreURL");
    driver.get(PreURL);
    tObj.getNewUserIdTextBox().clear();
    tObj.getNewUserIdTextBox().sendKeys(dataTable.getData("General_Data", "UserId"));
    tObj.getNewPasswordTextBox().sendKeys(dataTable.getData("General_Data", "Password"));
    tObj.getNewLoginButton().click();

    HashMap<Integer, HashMap<Integer, ArrayList<String>>> pre_reportData = new HashMap<Integer, HashMap<Integer, ArrayList<String>>>();
    HashMap<Integer, HashMap<Integer, ArrayList<String>>> post_Pages_Data = new HashMap<Integer, HashMap<Integer, ArrayList<String>>>();

    try {
        Thread.sleep(1000);
        WebElement folderFrame1 = null;
        if (driver.getTitle().contains("Information Console")) {
            String[] foldersName = dataTable.getData("General_Data", "PreReportFolderName").split(";");
            int LengthFolder = foldersName.length;
            for (int folderLoop = 0; folderLoop < foldersName.length - 1; folderLoop++) {
                folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame1);

                if (waitForElement(driver, By.linkText(foldersName[folderLoop]), 100)) {
                    driver.findElement(By.linkText(foldersName[folderLoop])).click();
                    report.updateTestLog("Report Navigation",
                            "Navigation to this folder" + foldersName[folderLoop] + "is PASSED", Status.PASS);

                } else {
                    report.updateTestLog("Report Navigation",
                            "Navigation to this folder" + foldersName[folderLoop] + "is failed", Status.FAIL);
                }
                driver.switchTo().defaultContent();
            }
            folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
            driver.switchTo().frame(folderFrame1);
            Thread.sleep(4000);
            driver.findElement(By.partialLinkText(foldersName[(LengthFolder - 1)])).click();
            driver.switchTo().defaultContent();
            folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
            driver.switchTo().frame(folderFrame1);
            String reportName = dataTable.getData("General_Data", "ReportName");
            waitForElement(driver, By.id("toolbarframe"), 100);
            driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
            String no_Of_Pages = driver
                    .findElement(By.xpath("//input[@name='editThis']/parent::td/following-sibling::td/font"))
                    .getText().trim();
            no_Of_Pages = no_Of_Pages.substring(3, no_Of_Pages.length());
            int no_OfPages = Integer.parseInt(no_Of_Pages);
            driver.switchTo().defaultContent();
            ArrayList<WebElement> no_of_rows = new ArrayList<WebElement>();
            no_of_rows = (ArrayList<WebElement>) driver
                    .findElements(By.xpath("//body[@onunload='onUnload()']/div/div/div"));
            HashMap<Integer, ArrayList<String>> table_data = null;
            ArrayList<WebElement> column_Values_Properties = new ArrayList<WebElement>();
            String dynaXpath;
            //   for (int l = 1; l <= 2; l++)
            for (int l = 1; l <= no_OfPages; l++) {

                folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame1);
                driver.switchTo().frame(driver.findElement(By.id("reportframe")));

                if (reportName.contains("MRF601")) {
                    strHeaderVal = mObj.getHeaderValuesrprt601();
                } else if (reportName.contains("MRF202"))
                    strHeaderVal = mObj.getHeaderValuesrprt202();
                else if (reportName.equalsIgnoreCase("MRA112") || reportName.equalsIgnoreCase("MRA114"))
                    strHeaderVal = mObj.getHeaderValuesrprtMRA112_all();
                else if (reportName.equalsIgnoreCase("MRA103"))
                    strHeaderVal = mObj.getrprt103AHeaderelementValues();
                else if (reportName.equalsIgnoreCase("MRF604"))
                    strHeaderVal = mObj.getHeaderValuesrprt604();
                else if (reportName.equalsIgnoreCase("MRM104"))
                    strHeaderVal = mObj.getHeaderValuesMRM104();
                else if (reportName.equalsIgnoreCase("MRF458"))
                    strHeaderVal = mObj.getHeaderValuesMRF458();
                else if (reportName.equalsIgnoreCase("MRF807"))
                    strHeaderVal = mObj.getHeaderValuesrprt807();
                else if (TC_ID.contains("Report_MRO219"))
                    strHeaderVal = mObj.getHeaderValuesPreMRO219();
                else if (TC_ID.contains("Report_MRA110_UKNOdata_Daily"))
                    strHeaderVal = mObj.getHeaderValuesMRA110_UK_NoData();
                else if (reportName.equalsIgnoreCase("MRF303"))
                    strHeaderVal = null;
                else {
                    strHeaderVal = mObj.getHeaderValuesPre();
                }
                no_of_rows = (ArrayList<WebElement>) driver
                        .findElements(By.xpath("//body[@onunload='onUnload()']/div/div/div"));
                table_data = new HashMap<Integer, ArrayList<String>>();
                for (int i = 2; i <= no_of_rows.size(); i++) {
                    //dynaXpath = "(//body[@onunload='onUnload()']/div/div/div)[" + i + "]//nobr"; //MRF303_Report
                    dynaXpath = "//body[@onunload='onUnload()']/div/div/div[" + i + "]/*/nobr";
                    column_Values_Properties = (ArrayList<WebElement>) driver.findElements(By.xpath(dynaXpath));
                    ArrayList<String> column_Values = new ArrayList<String>();
                    if (column_Values_Properties.size() > 0) {
                        for (int j = 0; j < column_Values_Properties.size(); j++) {
                            column_Values.add(j, column_Values_Properties.get(j).getText());
                        }
                    }

                    table_data.put(i, column_Values);

                }
                pre_reportData.put(l, table_data);
                flagPrepg = 1;
                if (flagPrepg == 0) {
                    report.updateTestLog("Pre Report" + reportName, "Data is not been stored from Page No" + l,
                            Status.FAIL);
                }

                if (l <= 3 || l > no_OfPages - 3) {
                    report.updateTestLog("Pre Report" + reportName, "Page No" + l, Status.PASS);
                }
                page.add(strHeaderVal);
                driver.switchTo().defaultContent();
                folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame1);
                driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
                driver.findElement(By.linkText("Next")).click();
                driver.switchTo().defaultContent();
                flagPrepg = 0;
            }
            pages.add(page);
        } else {
            report.updateTestLog("Prereport Folders", "Pre Report folders pages is not opened", Status.FAIL);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    String PostURL = dataTable.getData("General_Data", "PostURL");
    driver.get(PostURL);

    tObj.getPostUserIdTextBox().clear();

    tObj.getPostUserIdTextBox().sendKeys(dataTable.getData("General_Data", "UserId"));
    tObj.getPostPasswordTextBox().sendKeys(dataTable.getData("General_Data", "Password"));
    tObj.getPostLoginButton().click();
    try {
        WebElement folderFrame = null;
        String[] postFolderName = dataTable.getData("General_Data", "PostReportFolderName").split(";");
        if (waitForElement(driver, By.id("acFileExplorer"), 4000)) {
            //System.out.println("test1");
            for (int folders = 0; folders < (postFolderName.length - 1); folders++) {
                driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame);

                String dynaXpathFolder1 = "//a[contains(@href,'" + postFolderName[folders] + "')]";

                //if (waitForElement(driver, By.linkText(postFolderName[folders]), 1000)) 
                if (waitForElement(driver, By.xpath(dynaXpathFolder1), 1000)) {
                    driver.findElement(By.linkText(postFolderName[folders])).click();
                    driver.switchTo().defaultContent();
                } else {
                    report.updateTestLog("Post Report Folder Navigation",
                            "Post Report Folder Navigation" + folderFrame + "Has failed", Status.FAIL);
                }
            }

            driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
            folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
            driver.switchTo().frame(folderFrame);
            String postReportName = dataTable.getData("General_Data", "PostReportName");

            //System.out.println("Post report name : " +postReportName);

            if (waitForElement(driver, By.linkText(postReportName), 1000)) {
                driver.findElement(By.linkText(postReportName)).click();
                //   System.out.println("Pass1");
                driver.switchTo().defaultContent();
                //   System.out.println("Pass2");
                driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                //   System.out.println("Pass3");
                folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame);
                //   System.out.println("Pass4");
                driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
                //   System.out.println("Pass5");
                String no_Of_Pages = driver
                        .findElement(
                                By.xpath("//input[@name='editThis']/parent::td/following-sibling::td/font"))
                        .getText().trim();
                no_Of_Pages = no_Of_Pages.substring(3, no_Of_Pages.length());
                int no_OfPages = Integer.parseInt(no_Of_Pages);
                driver.switchTo().defaultContent();
                HashMap<Integer, ArrayList<String>> post_Page_TableData = null;
                //   for (int i = 1; i <= 2; i++)

                for (int i = 1; i <= no_OfPages; i++) {
                    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                    folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                    driver.switchTo().frame(folderFrame);
                    driver.switchTo().frame(driver.findElement(By.id("reportframe")));
                    /* Changes on 11/04/2016
                     * 
                     * 
                     */
                    if (postReportName.contains("MRF601")) {
                        strHeaderVal = mObj.getHeaderValuesrprt601();
                    } else if (postReportName.contains("MRF202"))
                        strHeaderVal = mObj.getHeaderValuesrprt202();
                    else if (postReportName.equalsIgnoreCase("MRA112")
                            || postReportName.equalsIgnoreCase("MRA114"))
                        strHeaderVal = mObj.getHeaderValuesrprtMRA112_all();
                    else if (postReportName.equalsIgnoreCase("MRA103"))
                        strHeaderVal = mObj.getrprt103AHeaderelementValues();
                    else if (postReportName.equalsIgnoreCase("MRF604"))
                        strHeaderVal = mObj.getHeaderValuesrprt604();
                    else if (postReportName.equalsIgnoreCase("MRM104"))
                        strHeaderVal = mObj.getHeaderValuesMRM104();
                    else if (postReportName.equalsIgnoreCase("MRF458"))
                        strHeaderVal = mObj.getHeaderValuesMRF458();
                    else if (postReportName.equalsIgnoreCase("MRF807"))
                        strHeaderVal = mObj.getHeaderValuesrprt807();
                    else if (TC_ID.contains("Report_MRO219"))
                        strHeaderVal = mObj.getHeaderValuesPreMRO219();
                    else if (TC_ID.contains("Report_MRA110_UKNOdata_Daily"))
                        strHeaderVal = mObj.getHeaderValuesMRA110_UK_NoData();
                    else if (postReportName.equalsIgnoreCase("MRF303"))
                        strHeaderVal = null;
                    else
                        strHeaderVal = mObj.getHeaderValuesPost();

                    List<WebElement> no_Of_Rows = driver
                            .findElements(By.xpath("//body[@onunload='onUnload()']/div/div/div"));
                    String dynaXpath;
                    ArrayList<WebElement> column_Values_Elements = new ArrayList<WebElement>();
                    //ArrayList<String> column_Values=new ArrayList<>();
                    post_Page_TableData = new HashMap<Integer, ArrayList<String>>();
                    for (int j = 2; j <= no_Of_Rows.size(); j++) {
                        dynaXpath = "//body[@onunload='onUnload()']/div/div/div[" + j + "]/*/nobr";
                        ArrayList<String> column_Values = new ArrayList<String>();
                        column_Values_Elements = (ArrayList<WebElement>) driver
                                .findElements(By.xpath(dynaXpath));
                        if (column_Values_Elements.size() > 0) {
                            for (int k = 0; k < column_Values_Elements.size(); k++) {
                                column_Values.add(k, column_Values_Elements.get(k).getText());
                            }
                        }

                        post_Page_TableData.put(j, column_Values);
                        //column_Values.clear();

                    }
                    post_Pages_Data.put(i, post_Page_TableData);
                    //System.out.println("Past Pages data is : " +post_Pages_Data);
                    // post_Page_TableData.clear();
                    flagPostPg = 1;
                    if (flagPostPg == 0)
                        report.updateTestLog("Post Report " + postReportName,
                                "Data is not been stored from Page No" + i, Status.FAIL);
                    if (i <= 3 || i > no_OfPages - 3) {
                        report.updateTestLog("Post Report " + postReportName, "Page No" + i, Status.PASS);
                        //System.out.println("Post Page data for page number: "+i+ "  is : " +post_Pages_Data.get(i));
                    }
                    postPage.add(strHeaderVal);

                    driver.switchTo().defaultContent();
                    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                    folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                    driver.switchTo().frame(folderFrame);
                    driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));

                    driver.findElement(By.linkText("Next")).click();
                    driver.switchTo().defaultContent();
                    waitForElement(driver, By.id("acFileExplorer"), 2000);

                    flagPostPg = 0;

                }
                Postpages.add(postPage);

                report.updateTestLog("Storing Data", "Data has been stored for Pre report", Status.PASS);

                compareHeaders();

                comparePreandPost(pre_reportData, post_Pages_Data);
            } else {
                report.updateTestLog("Post Report Navigation", "Not able to find Report Folder", Status.FAIL);
            }
        } else {
            report.updateTestLog("Post Report Folder Navigation",
                    "Not able to find Post Report Folder structure", Status.FAIL);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:businesscomponents.ReportcomparisonComponents1.java

public void completeReportComparisonMRF303() throws Exception

{
    //completeReportComparisonNew();
    //Login to Pre
    String PreURL = dataTable.getData("General_Data", "PreURL");
    driver.get(PreURL);/* ww  w.  ja v a2  s  . co  m*/
    tObj.getNewUserIdTextBox().clear();
    tObj.getNewUserIdTextBox().sendKeys(dataTable.getData("General_Data", "UserId"));
    tObj.getNewPasswordTextBox().sendKeys(dataTable.getData("General_Data", "Password"));
    tObj.getNewLoginButton().click();

    HashMap<Integer, HashMap<Integer, ArrayList<String>>> pre_reportData = new HashMap<Integer, HashMap<Integer, ArrayList<String>>>();
    HashMap<Integer, HashMap<Integer, ArrayList<String>>> post_Pages_Data = new HashMap<Integer, HashMap<Integer, ArrayList<String>>>();
    try {
        WebElement folderFrame1 = null;
        if (driver.getTitle().contains("Information Console")) {
            String[] foldersName = dataTable.getData("General_Data", "PreReportFolderName").split(";");
            int LengthFolder = foldersName.length;
            for (int folderLoop = 0; folderLoop < foldersName.length - 1; folderLoop++) {
                folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame1);

                if (waitForElement(driver, By.linkText(foldersName[folderLoop]), 100)) {
                    driver.findElement(By.linkText(foldersName[folderLoop])).click();
                    report.updateTestLog("Report Navigation",
                            "Navigation to this folder" + foldersName[folderLoop] + "is PASSED", Status.PASS);

                } else {
                    report.updateTestLog("Report Navigation",
                            "Navigation to this folder" + foldersName[folderLoop] + "is failed", Status.FAIL);
                }
                driver.switchTo().defaultContent();
            }
            folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
            driver.switchTo().frame(folderFrame1);
            Thread.sleep(2000);
            driver.findElement(By.partialLinkText(foldersName[(LengthFolder - 1)])).click();
            driver.switchTo().defaultContent();
            folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
            driver.switchTo().frame(folderFrame1);
            String reportName = dataTable.getData("General_Data", "ReportName");
            waitForElement(driver, By.id("toolbarframe"), 50);
            driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
            String no_Of_Pages = driver
                    .findElement(By.xpath("//input[@name='editThis']/parent::td/following-sibling::td/font"))
                    .getText().trim();
            no_Of_Pages = no_Of_Pages.substring(3, no_Of_Pages.length());
            int no_OfPages = Integer.parseInt(no_Of_Pages);
            driver.switchTo().defaultContent();
            ArrayList<WebElement> no_of_rows = new ArrayList<WebElement>();
            no_of_rows = (ArrayList<WebElement>) driver
                    .findElements(By.xpath("//body[@onunload='onUnload()']/div/div/div"));
            HashMap<Integer, ArrayList<String>> table_data_1 = null;
            HashMap<Integer, ArrayList<String>> table_data_2 = null;
            ArrayList<WebElement> column_Values_Properties_1 = new ArrayList<WebElement>();
            ArrayList<WebElement> column_Values_Properties_2 = new ArrayList<WebElement>();
            String dynaXpath;
            for (int l = 1; l <= no_OfPages; l++) {
                folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame1);
                driver.switchTo().frame(driver.findElement(By.id("reportframe")));
                no_of_rows = (ArrayList<WebElement>) driver
                        .findElements(By.xpath("//body[@onunload='onUnload()']/div/div/div"));

                table_data_1 = new HashMap<Integer, ArrayList<String>>();
                table_data_2 = new HashMap<Integer, ArrayList<String>>();

                if (l < no_OfPages) {
                    for (int i = 2; i <= no_of_rows.size(); i++) {
                        if (i == (no_of_rows.size() - 3)) {
                            ArrayList<String> column_Values_dummy_1 = new ArrayList<String>();
                            column_Values_dummy_1.add("ByPass");
                            table_data_1.put(i, column_Values_dummy_1);
                        } else {
                            dynaXpath = "(//body[@onunload='onUnload()']/div/div/div)[" + i + "]//nobr";
                            column_Values_Properties_1 = (ArrayList<WebElement>) driver
                                    .findElements(By.xpath(dynaXpath));
                            ArrayList<String> column_Values_1 = new ArrayList<String>();
                            if (column_Values_Properties_1.size() > 0) {
                                for (int j = 0; j < column_Values_Properties_1.size(); j++) {
                                    column_Values_1.add(j, column_Values_Properties_1.get(j).getText());
                                }
                            }
                            table_data_1.put(i, column_Values_1);

                        }
                    }
                    pre_reportData.put(l, table_data_1);

                } else if (l == no_OfPages) {
                    for (int i = 2; i <= no_of_rows.size() - 1; i++) {
                        dynaXpath = "//body[@onunload='onUnload()']/div/div/div[" + i + "]//nobr";
                        column_Values_Properties_2 = (ArrayList<WebElement>) driver
                                .findElements(By.xpath(dynaXpath));
                        ArrayList<String> column_Values_2 = new ArrayList<String>();
                        if (column_Values_Properties_2.size() > 0) {
                            for (int j = 0; j < column_Values_Properties_2.size(); j++) {
                                column_Values_2.add(j, column_Values_Properties_2.get(j).getText());
                            }
                        }
                        table_data_2.put(i, column_Values_2);
                    }
                    pre_reportData.put(l, table_data_2);
                }
                if (l <= 3 || l > no_OfPages - 3) {
                    report.updateTestLog("Pre Report" + reportName, "Page No" + l, Status.PASS);
                }

                driver.switchTo().defaultContent();
                folderFrame1 = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame1);
                driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
                driver.findElement(By.linkText("Next")).click();
                driver.switchTo().defaultContent();

            }

            System.out.println("Pre data is :" + pre_reportData);

        }

        else {
            report.updateTestLog("Prereport Folders", "Pre Report folders pages is not opened", Status.FAIL);
        }

    } catch (Exception e) {
        System.out.println("Exception is :" + e);
    }

    String PostURL = dataTable.getData("General_Data", "PostURL");
    driver.get(PostURL);

    tObj.getPostUserIdTextBox().clear();

    tObj.getPostUserIdTextBox().sendKeys(dataTable.getData("General_Data", "UserId"));
    tObj.getPostPasswordTextBox().sendKeys(dataTable.getData("General_Data", "Password"));
    tObj.getPostLoginButton().click();

    try {
        WebElement folderFrame = null;
        String[] postFolderName = dataTable.getData("General_Data", "PostReportFolderName").split(";");
        if (waitForElement(driver, By.id("acFileExplorer"), 4000)) {
            //System.out.println("test1");
            for (int folders = 0; folders < (postFolderName.length - 1); folders++) {
                driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame);

                String dynaXpathFolder1 = "//a[contains(@href,'" + postFolderName[folders] + "')]";

                //if (waitForElement(driver, By.linkText(postFolderName[folders]), 1000)) 
                if (waitForElement(driver, By.xpath(dynaXpathFolder1), 1000)) {
                    driver.findElement(By.linkText(postFolderName[folders])).click();
                    driver.switchTo().defaultContent();
                } else {
                    report.updateTestLog("Post Report Folder Navigation",
                            "Post Report Folder Navigation" + folderFrame + "Has failed", Status.FAIL);
                }
            }

            driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
            folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
            driver.switchTo().frame(folderFrame);
            String postReportName = dataTable.getData("General_Data", "PostReportName");

            if (waitForElement(driver, By.linkText(postReportName), 1000)) {
                driver.findElement(By.linkText(postReportName)).click();
                driver.switchTo().defaultContent();
                driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                driver.switchTo().frame(folderFrame);
                driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));
                String no_Of_Pages = driver
                        .findElement(
                                By.xpath("//input[@name='editThis']/parent::td/following-sibling::td/font"))
                        .getText().trim();
                no_Of_Pages = no_Of_Pages.substring(3, no_Of_Pages.length());
                int no_OfPages = Integer.parseInt(no_Of_Pages);
                driver.switchTo().defaultContent();
                HashMap<Integer, ArrayList<String>> post_Page_TableData_1 = null;
                HashMap<Integer, ArrayList<String>> post_Page_TableData_2 = null;

                for (int i = 1; i <= no_OfPages; i++) {

                    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                    folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                    driver.switchTo().frame(folderFrame);
                    driver.switchTo().frame(driver.findElement(By.id("reportframe")));

                    List<WebElement> no_Of_Rows = driver
                            .findElements(By.xpath("//body[@onunload='onUnload()']/div/div/div"));
                    String dynaXpath_1;
                    ArrayList<WebElement> column_Values_Elements_1 = new ArrayList<WebElement>();
                    ArrayList<WebElement> column_Values_Elements_2 = new ArrayList<WebElement>();
                    //ArrayList<String> column_Values=new ArrayList<>();
                    post_Page_TableData_1 = new HashMap<Integer, ArrayList<String>>();
                    post_Page_TableData_2 = new HashMap<Integer, ArrayList<String>>();
                    if (i < no_OfPages) {

                        for (int j = 2; j <= no_Of_Rows.size(); j++) {
                            if (j == no_Of_Rows.size() - 3) {
                                ArrayList<String> column_Values_dummy = new ArrayList<String>();
                                column_Values_dummy.add("ByPass");
                                post_Page_TableData_1.put(j, column_Values_dummy);
                            }

                            else {
                                dynaXpath_1 = "(//body[@onunload='onUnload()']/div/div/div)[" + j + "]/*/nobr";
                                ArrayList<String> column_Values_post_1 = new ArrayList<String>();
                                column_Values_Elements_1 = (ArrayList<WebElement>) driver
                                        .findElements(By.xpath(dynaXpath_1));
                                if (column_Values_Elements_1.size() > 0) {
                                    for (int k = 0; k < column_Values_Elements_1.size(); k++) {
                                        column_Values_post_1.add(k, column_Values_Elements_1.get(k).getText());
                                    }
                                }

                                post_Page_TableData_1.put(j, column_Values_post_1);
                                //column_Values.clear();
                            }
                        }
                        post_Pages_Data.put(i, post_Page_TableData_1);
                    }

                    if (i == no_OfPages) {
                        for (int j = 2; j <= no_Of_Rows.size() - 1; j++) {
                            dynaXpath_1 = "//body[@onunload='onUnload()']/div/div/div[" + j + "]/*/nobr";
                            ArrayList<String> column_Values_post_2 = new ArrayList<String>();
                            column_Values_Elements_2 = (ArrayList<WebElement>) driver
                                    .findElements(By.xpath(dynaXpath_1));
                            if (column_Values_Elements_2.size() > 0) {
                                for (int k = 0; k < column_Values_Elements_2.size(); k++) {
                                    column_Values_post_2.add(k, column_Values_Elements_2.get(k).getText());
                                }
                            }

                            post_Page_TableData_2.put(j, column_Values_post_2);
                            //column_Values.clear();

                        }
                        post_Pages_Data.put(i, post_Page_TableData_2);
                    }

                    if (i <= 3 || i > no_OfPages - 3) {
                        report.updateTestLog("Post Report " + postReportName, "Page No" + i, Status.PASS);
                        //System.out.println("Post Page data for page number: "+i+ "  is : " +post_Pages_Data.get(i));
                    }
                    driver.switchTo().defaultContent();
                    driver.switchTo().frame(driver.findElement(By.id("acFileExplorer")));
                    folderFrame = driver.findElement(By.xpath("//frame[@name='main']"));
                    driver.switchTo().frame(folderFrame);
                    driver.switchTo().frame(driver.findElement(By.id("toolbarframe")));

                    driver.findElement(By.linkText("Next")).click();
                    driver.switchTo().defaultContent();
                    waitForElement(driver, By.id("acFileExplorer"), 2000);

                }

                report.updateTestLog("Storing Data", "Data has been stored for Pre and post reports",
                        Status.PASS);
                System.out.println("Post Data is : " + post_Pages_Data);
                //compareHeaders();

                comparePreandPost(pre_reportData, post_Pages_Data);
            } else {
                report.updateTestLog("Post Report Navigation", "Not able to find Report Folder", Status.FAIL);
            }
        } else {
            report.updateTestLog("Post Report Folder Navigation",
                    "Not able to find Post Report Folder structure", Status.FAIL);
        }
    } catch (Exception e) {
        System.out.println("in post block");
        System.out.println("Exception is :" + e);
    }
}

From source file:businessFramework.module.gibddMedicalExamination.modals.patientModel.PatientModelModal.java

/**
 *        " "/* w  w  w.  j  a  va 2  s  . co  m*/
 */
public void fillFieldsPatientModel(GibddMedicalExaminationData gMPData) {
    getName().setValue(gMPData.getPatientModelName()); // ? ?   "?"
    //Todo   ?  ,  ? ?: css selector: .n2o-modal-container]] -> class name: n2o-form-container]] -> css selector: [data-field-id*='gender']]] -> xpath: //label[contains(string(), ' ?')]/input]
    /**
     * getCheckboxesGenderGroup().check(gMPData.getPatientModelGenderMan(), true);            //  ? 1 - '?' , 2 - '?', 3 - '? '   ? ""
     * getCheckboxesGenderGroup().check(gMPData.getPatientModelGenderFemale(), true);
     * getCheckboxesGenderGroup().check(gMPData.getPatientModelGenderIndefinite(), true);
     */
    this.getPatientModelForm().findElement(By.xpath("(//input[@name='gender'])[1]")).click();
    this.getPatientModelForm().findElement(By.xpath("(//input[@name='gender'])[2]")).click();
    this.getPatientModelForm().findElement(By.xpath("(//input[@name='gender'])[3]")).click();
    getSocial().setValue(gMPData.getPatientModelSocial()); //    
    getGenderRadio().radioButtonPress("?"); //  ''   
    getCheckboxesLicenceCategory().check(gMPData.getLicenseCategoryA(), true); //  ? 'A', 'A1', 'B', 'B1'   ?  
    getCheckboxesLicenceCategory().check(gMPData.getLicenseCategoryA1(), true);
    getCheckboxesLicenceCategory().check(gMPData.getLicenseCategoryB(), true);
    getCheckboxesLicenceCategory().check(gMPData.getLicenseCategoryB1(), true);

    fillAfFields("0", "50", "10", "", null, null); //     "????   ??"
    clickAfAddNewButton();
    checkResult("0,10,20,30,40,50");
    fillAfFields("0", "50", "10", "??", null, null);
    clickAfAddNewButton();
    checkResult("0,10,20,30,40,50, 0.0,0.10,1.8,2.6,3.4,4.2");
    fillAfFields(null, null, null, null, "1", "12");
    clickAfManualAddButton();
    checkResult("0,10,20,30,40,50, 0.0,0.10,1.8,2.6,3.4,4.2, 1.12");
}

From source file:businessFramework.module.gibddMedicalExamination.modals.patientModel.PatientModelModal.java

/**
 *        " " ? /*ww w . j  av  a2  s . c om*/
 */
public void fillFieldsPatientAdditionalModel(GibddMedicalExaminationData gMPAData) {
    getName().setValue(gMPAData.getPatientModelName()); // ? ?   "?"
    /**
    getCheckboxesGenderGroup().check(gMPAData.getPatientModelGenderMan(), true);              //  ? 1 - '?' , 2 - '?', 3 - '? '   ? ""
    getCheckboxesGenderGroup().check(gMPAData.getPatientModelGenderFemale(), true);
     */
    this.getPatientModelForm().findElement(By.xpath("(//input[@name='gender'])[1]")).click();
    this.getPatientModelForm().findElement(By.xpath("(//input[@name='gender'])[2]")).click();
    getSocial().setValue(gMPAData.getPatientModelSocial()); //    
    getGenderRadio().radioButtonPress("?"); //  ''   
    getCheckboxesLicenceCategory().check(gMPAData.getLicenseCategoryM(), true); //  ? 'M', 'Tm', 'Tb'   ?  
    getCheckboxesLicenceCategory().check(gMPAData.getLicenseCategoryTm(), true);
    getCheckboxesLicenceCategory().check(gMPAData.getLicenseCategoryTb(), true);

    fillAfFields("51", "100", "10", "", null, null); //     "????   ??"
    clickAfAddNewButton();
    checkResult("51,61,71,81,91");
    fillAfFields("51", "100", "10", "??", null, null);
    clickAfAddNewButton();
    checkResult("51,61,71,81,91, 4.3,5.1,5.11,6.9,7.7");
    fillAfFields(null, null, null, null, "10", "12");
    clickAfManualAddButton();
    checkResult("51,61,71,81,91, 4.3,5.1,5.11,6.9,7.7, 10.12");
}

From source file:ca.nrc.cadc.caom2.ui.server.ObservationViewPage.java

License:Open Source License

public void ensureLoaded() throws Exception {
    final List<String> h3headers = new ArrayList<>();
    h3headers.add("Chunk");

    final List<String> h2headers = new ArrayList<>();
    h2headers.add("SimpleObservation");
    h2headers.add("Plane");
    h2headers.add("Artifact");
    h2headers.add("Part");

    for (final String header : h3headers) {
        final String xpath = "//h3[contains(text(),'" + header + "')]";
        find(By.xpath(xpath));
    }/*from  w  w  w . ja  v a 2 s. c  o m*/

    for (final String h2header : h2headers) {
        final String xpath = "//h2[contains(text(),'" + h2header + "')]";
        find(By.xpath(xpath));
    }
}

From source file:ca.nrc.cadc.search.integration.AbstractSearchFormPage.java

License:Open Source License

void verifyFormInputError(final String inputID) throws Exception {
    waitForElementPresent(//ww w .j a  v  a 2 s .c  o  m
            By.xpath("//div[@id='" + inputID + "_input_decorate'][contains(@class,'has-error')]"));
}

From source file:ca.nrc.cadc.search.integration.AbstractSearchFormPage.java

License:Open Source License

void verifyFormInputMessage(final String inputID, final boolean errorExpected, final String expectedMessage)
        throws Exception {
    if (errorExpected) {
        verifyFormInputError(inputID);//from w  w w  . j  a  va  2s.  c o m
    }

    final By contents = By.xpath(String.format(CONTENT_LOCATOR_XPATH, (inputID + "_details")));

    if (!Objects.equals(expectedMessage, "")) {
        waitForTextPresent(contents, expectedMessage);
    } else {
        WebElement contentEl = find(contents);
        if (!contentEl.getText().equals("")) {
            throw new Exception();
        }
    }
}

From source file:ca.nrc.cadc.search.integration.AbstractSearchFormPage.java

License:Open Source License

void verifyFormInputMessageMatches(final String inputID, final boolean errorExpected, final String messageRegex)
        throws Exception {
    if (errorExpected) {
        verifyFormInputError(inputID);/* w ww.  ja va  2  s  .  co m*/
    }

    verifyTextMatches(By.xpath(String.format(CONTENT_LOCATOR_XPATH, (inputID + "_details"))), messageRegex);
}

From source file:ca.nrc.cadc.search.integration.AbstractSearchFormPage.java

License:Open Source License

void hideInputBox(final String inputID) throws Exception {
    click(By.xpath(String.format(CONTENT_LOCATOR_XPATH, (inputID + "_details"))));
    waitForElementInvisible(By.id(inputID));
}

From source file:ca.nrc.cadc.search.integration.AbstractSearchFormPage.java

License:Open Source License

void summonTooltip(final String baseID) throws Exception {
    final By tooltipIconTriggerBy = By.xpath("//div[@id='" + baseID + "_formgroup']/div");

    waitForElementPresent(tooltipIconTriggerBy);
    waitForElementVisible(tooltipIconTriggerBy);

    click(tooltipIconTriggerBy);//from   ww w.ja v a2 s . c  o  m

    waitForElementPresent(By.xpath("//div[@id='" + baseID + "_formgroup']/div[2]"));
    waitForElementVisible(By.xpath("//div[@id='" + baseID + "_formgroup']/div[2]"));
}