List of usage examples for org.openqa.selenium By xpath
public static By xpath(String xpathExpression)
From source file:bst.cpo.automation.dm.actions.SystemOverview_Actions.java
public void Clear_Click() { //<input type="reset" class="pure-button" value="Clear" ng-click="resetSearch()"> WebElement element = DMDriver/*ww w.ja v a 2s . com*/ .findElement(By.xpath("//*[@id='app']/div/div[4]/div/div/div[2]/div[1]/div[1]/form/input[3]")); element.click(); }
From source file:bst.cpo.automation.dm.actions.SystemOverview_Actions.java
public void Close_Properties_Panel() { logThis("Closing the properties panel"); WebElement element = DMDriver/*ww w. java2 s . c o m*/ .findElement(By.xpath("//*[@id='app']/div/div[4]/div/div/div[2]/div[1]/div[5]/h2/i")); element.click(); }
From source file:budget.WebDriverManager.java
private static void refreshAccountsWF() { int attempts = 3; int attempt = 1; Boolean isDownloaded = false; List<String> credentials = getCredentials(4); while ((attempt <= attempts) && !isDownloaded) { try {//from w w w.ja va 2s . c om driver = new HtmlUnitDriver(true); wait = new WebDriverWait(driver, timeout); java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit") .setLevel(java.util.logging.Level.OFF); java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF); driver.get("Http://www.wellsfargo.com"); driver.findElement(By.id("userid")).clear(); driver.findElement(By.id("userid")).sendKeys(credentials.get(0)); driver.findElement(By.id("password")).clear(); driver.findElement(By.id("password")).sendKeys(credentials.get(1)); driver.findElement(By.id("btnSignon")).click(); waitAndClick(driver, wait, By.xpath("//th[@id='cashAccount1']/a")); runQueryWF(driver, wait, 4); runQueryWF(driver, wait, 5); runQueryWF(driver, wait, 6); driver.findElement(By.linkText("Sign Off")).click(); driver.close(); driver.quit(); isDownloaded = true; } catch (Exception ex) { driver.quit(); trace(ex.getMessage(), taLog); clearBatch(stmt); attempt++; } ; } trace((isDownloaded ? "Downloaded" : "Not downloaded") + " from " + attempt + ((attempt == 1) ? " attempt" : " attemps"), taLog); executeBatch(stmt, taLog); }
From source file:budget.WebDriverManager.java
private static void runQueryWF(WebDriver driver, WebDriverWait wait, int account) { String date;/*w w w . j a v a 2 s .com*/ String Analytics; String Category; Double amount; String accountName = getAccountName(stmt, account); //Selecting and wait for certain account page if (account != 4) { new Select(driver.findElement(By.id("accountDropdown"))).selectByIndex(account - 4); driver.findElement(By.name("accountselection")).click(); } wait.until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.className("moremarginbottom")), accountName)); //Gatherng total amount if (account == 6) { String limitStr = driver.findElement(By.xpath("//table[@id='balancedetailstable']/tbody/tr/td")) .getText(); String balanceStr = driver.findElement(By.xpath("//table[@id='balancedetailstable']/tbody/tr[3]/td")) .getText(); //amount = convertStringAmountToDouble(balanceStr) - convertStringAmountToDouble(limitStr); amount = convertStringAmountToDouble(balanceStr); //just for SECURE CARD } else { amount = convertStringAmountToDouble( driver.findElement(By.className("availableBalanceTotalAmount")).getText()); } addTotal(stmt, getTimestamp(), account, amount, taLog); //Gathering transactinos if (account == 6) { String strAmount; driver.findElement(By.id("a.creditcardtempauth")).click(); waitForElement(wait, By.xpath("//tbody[@id='tempAuthSection']/tr")); List<WebElement> rows = driver.findElements(By.xpath("//tbody[@id='tempAuthSection']/tr")); for (WebElement row : rows) { if (!"You have no temporary authorizations for this account.".equals(row.getText())) { date = rotateDate(row.findElement(By.className("rowhead")).getText(), "mm/dd/yy"); Analytics = prepareTextForQuery(row.findElement(By.className("text")).getText()); strAmount = row.findElements(By.className("amount")).get(0).getText(); if ("+".equals(strAmount.substring(0, 1))) { amount = convertStringAmountToDouble(strAmount); } else { amount = -convertStringAmountToDouble(strAmount); } addTransaction(true, stmt, date, account, "", Analytics, amount, true, taLog); } } rows = driver.findElements(By.xpath("//table[@id='CreditCardTransactionTable']/tbody[4]/tr")); for (WebElement row : rows) { if (row.findElements(By.className("rowhead")).size() == 1) { if (!"".equals(row.findElement(By.className("rowhead")).getText())) { date = rotateDate(row.findElement(By.className("rowhead")).getText(), "mm/dd/yy"); WebElement cell = row.findElement(By.className("text")); Analytics = prepareTextForQuery(cell.findElement(By.xpath("span")).getText()); strAmount = row.findElements(By.className("amount")).get(0).getText(); if ("+".equals(strAmount.substring(0, 1))) { amount = convertStringAmountToDouble(strAmount); } else { amount = -convertStringAmountToDouble(strAmount); } if (amount > 0) { Category = ""; } else { cell.findElement(By.className("detailsSection")).click(); waitForElement(wait, By.xpath("//table[@id='expandCollapseTable']/tbody/tr[2]/td[2]")); Category = cell .findElement(By.xpath("//table[@id='expandCollapseTable']/tbody/tr[2]/td[2]")) .getText(); } addTransaction(true, stmt, date, account, Category, Analytics, amount, false, taLog); } } } } else { driver.findElement(By.id("timeFilter")).click(); new Select(driver.findElement(By.id("timeFilter"))).selectByVisibleText("Date Range"); waitAndClick(driver, wait, By.name("Submit")); int itemsOnPage; if (driver.findElements(By.className("emdisclosure")).size() == 1) { itemsOnPage = Integer.parseInt(driver.findElement(By.className("emdisclosure")).getText() .replace("(", "").replace(" transactions per page)", "")); } else { itemsOnPage = 0; } int itemsCounter; Boolean isPending = false; List<WebElement> lstAmounts; do { itemsCounter = 0; List<WebElement> rows = driver .findElements(By.xpath("//table[@id='DDATransactionTable']/tbody/tr")); for (WebElement row : rows) { if (row.findElement(By.className("text")).getText().contains("Pending transactions")) { isPending = true; } if (row.findElement(By.className("text")).getText().contains("Posted Transactions")) { isPending = false; } if (row.findElements(By.className("rowhead")).size() == 1) { date = rotateDate(row.findElement(By.className("rowhead")).getText(), "mm/dd/yy"); Analytics = prepareTextForQuery(row.findElement(By.className("text")).getText()); lstAmounts = row.findElements(By.className("amount")); if (!" ".equals(lstAmounts.get(0).getText())) { amount = convertStringAmountToDouble(lstAmounts.get(0).getText()); } if (!" ".equals(lstAmounts.get(1).getText())) { amount = -convertStringAmountToDouble(lstAmounts.get(1).getText()); } addTransaction(true, stmt, date, account, "", Analytics, amount, isPending, taLog); itemsCounter++; } } if (itemsCounter == itemsOnPage) { driver.findElement(By.linkText("Next >")).click(); } } while (itemsCounter == itemsOnPage); } }
From source file:businesscomponents.ReportCompare1.java
public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub WebDriver driver = new FirefoxDriver(); driver.get("http://148.173.174.122:8900/acadmin/?serverURL=http://wpqwa551:8000"); driver.manage().window().maximize(); String strUserName = "kgoutham"; String strPassWord = "kgoutham"; driver.findElement(By.name("userID")).clear(); driver.findElement(By.name("userID")).sendKeys(strUserName); driver.findElement(By.name("Password")).clear(); driver.findElement(By.name("Password")).sendKeys(strPassWord); driver.findElement(By.name("loginBtn")).click(); Thread.sleep(1200);//from w ww.ja v a 2 s.c o m System.out.println("Page title is: " + driver.getTitle()); if (driver.getTitle().contains("Files & Folders")) { driver.findElement(By.id("Jobs")).click(); Thread.sleep(2500); driver.switchTo().defaultContent(); WebElement frame = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(frame); Thread.sleep(1200); if (driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).isDisplayed()) { try { JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]"))); } catch (Exception e) { driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).click(); } System.out.println("Clicking on Completed Tabs"); } else { System.out.println("Failed:Unable to Find the Completed Tab section"); } Thread.sleep(1200); WebElement frame1 = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(frame1); String strValue = "MRF412"; driver.findElement(By.id("FilterText")).clear(); driver.findElement(By.id("FilterText")).sendKeys(strValue); Thread.sleep(1200); driver.findElement(By.xpath("//input[@value='Apply']")).click(); Thread.sleep(3500); WebElement frame2 = driver.findElement(By.id("ifrListFrame")); driver.switchTo().frame(frame2); if (driver.findElement(By.xpath("(//a[contains(text(),'MRF412_reportcheck.ROI')])[1]")).isDisplayed()) { String oldTab = driver.getWindowHandle(); driver.findElement(By.xpath("(//a[contains(text(),'MRF412_reportcheck.ROI')])[1]")).click(); Thread.sleep(5000); ArrayList<String> newTab = new ArrayList<String>(driver.getWindowHandles()); newTab.remove(oldTab); // change focus to new tab driver.switchTo().window(newTab.get(0)); WebElement frame3 = driver.findElement(By.id("reportframe")); driver.switchTo().frame(frame3); String strPageSource = driver.getPageSource(); CommonData.strPageSource = strPageSource; String strPageTitle = driver.findElement(By.xpath("//div[contains(@id,'water')]")).getText(); CommonData.strPageTitle = strPageTitle; if (strPageTitle.contains("MultiUserTest License")) { System.out.println("Verifying the MultiUserTest License page is displayed"); List<WebElement> products = driver .findElements(By.xpath("//div[contains(@onmouseover,'Partner Name')]")); ArrayList<String> strPartnerName = CommonData.strPartnerName; ArrayList<String> strInvoiceNumber = CommonData.strInvoiceNumber; ArrayList<String> strTotalPayment = CommonData.strTotalPayment; ArrayList<String> strSENumber = CommonData.strSENumber; ArrayList<String> strPaymentMarket = CommonData.strPaymentMarket; ArrayList<String> strPaymentunit = CommonData.strPaymentunit; ArrayList<String> strLiabilityUnit = CommonData.strLiabilityUnit; ArrayList<String> strLiabilityCurrency = CommonData.strLiabilityCurrency; ArrayList<String> strMarketCurrency = CommonData.strMarketCurrency; ArrayList<String> strInvoiceReleaseDate = CommonData.strInvoiceReleaseDate; ArrayList<String> strUserId = CommonData.strUserId; for (int i = 1; i <= products.size(); i++) { System.out.println( "-----------------DISPLAYING LIST OF TABLE VALUES----------------------->: " + i); String strPartnerNameList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Partner Name')])[" + i + "]")) .getText(); strPartnerName.add(strPartnerNameList); System.out.println("Displaying the Partner Name list :" + strPartnerNameList); String strInvoiceNumberList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Invoice Number')])[" + i + "]")) .getText(); strInvoiceNumber.add(strInvoiceNumberList); System.out.println("Displaying the Invoice Number list :" + strInvoiceNumberList); String strTotalPaymentList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + j + "]")) .getText(); } else { strTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + i + "]")) .getText(); } strTotalPayment.add(strTotalPaymentList); System.out.println("Displaying the Total Payment list :" + strTotalPaymentList); String strSENumberList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'SE Number')])[" + i + "]")) .getText(); strSENumber.add(strSENumberList); System.out.println("Displaying the SE Number list :" + strSENumberList); String strPaymentMarketList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Payment Market')])[" + i + "]")) .getText(); strPaymentMarket.add(strPaymentMarketList); System.out.println("Displaying the Payment Market list :" + strPaymentMarketList); String strPaymentUnitList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Payment Unit')])[" + i + "]")) .getText(); strPaymentunit.add(strPaymentUnitList); System.out.println("Displaying the Payment Unit list :" + strPaymentUnitList); String strLiabilityUnitList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Unit')])[" + i + "]")) .getText(); strLiabilityUnit.add(strLiabilityUnitList); System.out.println("Displaying the Liability Unit list :" + strLiabilityUnitList); String strLiabilityCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Currency')])[" + i + "]")) .getText(); strLiabilityCurrency.add(strLiabilityCurrencyList); System.out.println("Displaying the Liability Currency list :" + strLiabilityCurrencyList); String strMarketCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Market Currency')])[" + i + "]")) .getText(); strMarketCurrency.add(strMarketCurrencyList); System.out.println("Displaying the Market Currency list :" + strMarketCurrencyList); String strInvoiceReleaseDateList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + j + "]")) .getText(); } else { strInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + i + "]")) .getText(); } strInvoiceReleaseDate.add(strInvoiceReleaseDateList); System.out .println("Displaying the Invoice release date list :" + strInvoiceReleaseDateList); String strUserIDList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'USER ID')])[" + i + "]")) .getText(); strUserId.add(strUserIDList); System.out.println("Displaying the UserId list :" + strUserIDList); } // for (int i = 0; i < products.size(); i++) { // System.out.println("############ CHECKING ########################"); // System.out.println(CommonData.strInvoiceNumber.get(i) + " Invoice Number"); // System.out.println(CommonData.strInvoiceReleaseDate.get(i) + " Invoice Release Date"); // System.out.println(CommonData.strTotalPayment.get(i) + " Total Payment"); // // } } else { System.out.println("MultiUserTest License is not displayed"); } driver.switchTo().defaultContent(); driver.close(); driver.switchTo().window(oldTab); // driver.get(" // http://148.173.174.122:8900/acadmin/?serverURL=http://wpqwa551:8000"); driver.get( "http://148.173.174.122:8900/acadmin/jobmanager.jsp?serverURL=http%3a%2f%2fwpqwa551%3a8000&volume=wpqwa551&daemonURL=http://wpqwa551:8100&daemonURL=http://wpqwa551:8100"); if (driver.findElement(By.xpath("//td[contains(text(),'System')]")).isDisplayed()) { System.out.println("--------------##### Focus Changed to old window #### -----------"); } else { System.out.println("---------Focus not changed---------------"); } driver.switchTo().defaultContent(); WebElement postframe = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(postframe); Thread.sleep(1200); if (driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).isDisplayed()) { try { JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]"))); } catch (Exception e) { driver.findElement(By.xpath("//a[contains(@onmouseover,'completedjobs')]")).click(); } System.out.println("Clicking on Completed Tabs"); } else { System.out.println("Failed:Unable to Find the Completed Tab section"); } Thread.sleep(5000); WebElement postframe1 = driver.findElement(By.id("TableFrame")); driver.switchTo().frame(postframe1); String strPostValue = "MRF412"; driver.findElement(By.id("FilterText")).clear(); driver.findElement(By.id("FilterText")).sendKeys(strPostValue); Thread.sleep(1200); driver.findElement(By.xpath("//input[@value='Apply']")).click(); Thread.sleep(3500); WebElement postframe2 = driver.findElement(By.id("ifrListFrame")); driver.switchTo().frame(postframe2); String postoldTab = driver.getWindowHandle(); driver.findElement(By.xpath("(//a[contains(text(),'MRF412_reportcheck.ROI')])[1]")).click(); Thread.sleep(5000); ArrayList<String> newTab_1 = new ArrayList<String>(driver.getWindowHandles()); newTab_1.remove(postoldTab); // change focus to new tab driver.switchTo().window(newTab_1.get(0)); WebElement postframe3 = driver.findElement(By.id("reportframe")); driver.switchTo().frame(postframe3); System.out.println("-############## COMPARING PRE-REPORT and POST-REPORT-##############--"); // String strPostPageSource = driver.getPageSource(); String strPostPageTitle = driver.findElement(By.xpath("//div[contains(@id,'water')]")).getText(); if (strPostPageTitle.contains(CommonData.strPageTitle)) { System.out.println( "Passed : Page Title is matching with Pre-report and Post-Report " + strPostPageTitle); for (int i = 1, k = 0; i <= CommonData.strPartnerName.size(); i++, k++) { System.out.println( "----------------->>> COMPARING LIST OF TABLE VALUES FORM PRE-REPORT AND POST-REPORT ----------------------->>>: " + i); String strPostPartnerNameList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Partner Name')])[" + i + "]")) .getText(); if (CommonData.strPartnerName.get(k).contains(strPostPartnerNameList)) { System.out.println("Passed : Partner Name is matching with Pre-report and Post-Report :" + strPostPartnerNameList); } else { System.out.println( "Failed : Partner Name is not matching with Pre-report and Post-Report :" + strPostPartnerNameList); } String strPostInvoiceNumberList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Invoice Number')])[" + i + "]")) .getText(); if (CommonData.strInvoiceNumber.get(k).contains(strPostInvoiceNumberList)) { System.out.println( "Passed : Post Invoice Number is matching with Pre-report and Post-Report :" + strPostInvoiceNumberList); } else { System.out.println( "Failed : Post Invoice Number is not matching with Pre-report and Post-Report :" + strPostInvoiceNumberList); } String strPostTotalPaymentList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strPostTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + j + "]")) .getText(); if (CommonData.strTotalPayment.get(k).contains(strPostTotalPaymentList)) { System.out.println( "Passed : Total Payment List is matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } else { System.out.println( "Failed : Total Payment List is not matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } } else { strPostTotalPaymentList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Total Payment')])[" + i + "]")) .getText(); if (CommonData.strTotalPayment.get(k).contains(strPostTotalPaymentList)) { System.out.println( "Passed : Total Payment List is matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } else { System.out.println( "Failed : Total Payment List is not matching with Pre-report and Post-Report :" + strPostTotalPaymentList); } } String strPostSENumberList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'SE Number')])[" + i + "]")) .getText(); if (CommonData.strSENumber.get(k).contains(strPostSENumberList)) { System.out .println("Passed : SE Number List is matching with Pre-report and Post-Report :" + strPostSENumberList); } else { System.out.println( "Failed : SE Number List is not matching with Pre-report and Post-Report :" + strPostSENumberList); } String strPostPaymentMarketList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Payment Market')])[" + i + "]")) .getText(); if (CommonData.strPaymentMarket.get(k).contains(strPostPaymentMarketList)) { System.out .println("Passed : Payment Market is matching with Pre-report and Post-Report :" + strPostPaymentMarketList); } else { System.out.println( "Failed : Payment Market is not matching with Pre-report and Post-Report :" + strPostPaymentMarketList); } String strPostPaymentUnitList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'Payment Unit')])[" + i + "]")) .getText(); if (CommonData.strPaymentunit.get(k).contains(strPostPaymentUnitList)) { System.out.println( "Passed : Payment Unit list is matching with Pre-report and Post-Report :" + strPostPaymentUnitList); } else { System.out.println( "Failed : Payment Unit list is not matching with Pre-report and Post-Report :" + strPostPaymentUnitList); } String strPostLiabilityUnitList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Unit')])[" + i + "]")) .getText(); if (CommonData.strLiabilityUnit.get(k).contains(strPostLiabilityUnitList)) { System.out.println( "Passed : Liability Unit list is matching with Pre-report and Post-Report :" + strPostLiabilityUnitList); } else { System.out.println( "Failed : Liability Unit list is not matching with Pre-report and Post-Report :" + strPostLiabilityUnitList); } String strPostLiabilityCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Liability Currency')])[" + i + "]")) .getText(); if (CommonData.strLiabilityCurrency.get(k).contains(strPostLiabilityCurrencyList)) { System.out.println( "Passed : Liability Currency list is matching with Pre-report and Post-Report :" + strPostLiabilityCurrencyList); } else { System.out.println( "Failed : Liability Currency list is not matching with Pre-report and Post-Report :" + strPostLiabilityCurrencyList); } String strPostMarketCurrencyList = driver .findElement( By.xpath("(//div[contains(@onmouseover,'Market Currency')])[" + i + "]")) .getText(); if (CommonData.strMarketCurrency.get(k).contains(strPostMarketCurrencyList)) { System.out.println( "Passed : Market Currency list is matching with Pre-report and Post-Report :" + strPostMarketCurrencyList); } else { System.out.println( "Failed : Market Currency list is not matching with Pre-report and Post-Report :" + strPostMarketCurrencyList); } String strPostInvoiceReleaseDateList; if (i > 1) { int j; if (i == 3) { j = i + 2; } else { j = i + 1; } strPostInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + j + "]")) .getText(); if (CommonData.strInvoiceReleaseDate.get(k).contains(strPostInvoiceReleaseDateList)) { System.out.println( "Passed : Invoice Release Date list is matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } else { System.out.println( "Failed : Invoice Release Date list is not matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } } else { strPostInvoiceReleaseDateList = driver.findElement(By.xpath( "(//div[contains(@onmouseover,'This is the difference in cost between Invoice Total and Market Totals')]/nobr)[" + i + "]")) .getText(); if (CommonData.strInvoiceReleaseDate.get(k).contains(strPostInvoiceReleaseDateList)) { System.out.println( "Passed : Invoice Release Date list is matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } else { System.out.println( "Failed : Invoice Release Date list is not matching with Pre-report and Post-Report :" + strPostInvoiceReleaseDateList); } } String strPostUserIDList = driver .findElement(By.xpath("(//div[contains(@onmouseover,'USER ID')])[" + i + "]")) .getText(); if (CommonData.strUserId.get(k).contains(strPostUserIDList)) { System.out.println("Passed : User ID list is matching with Pre-report and Post-Report :" + strPostUserIDList); } else { System.out.println( "Failed : User ID list is not matching with Pre-report and Post-Report :" + strPostUserIDList); } } driver.switchTo().defaultContent(); driver.close(); driver.switchTo().window(postoldTab); System.out.println( "########################## COMPLETED VALIDATIONS ALL ARE MATCHING ##################################"); } else { System.out.println("Failed : Page Title is not matching with Pre-report and Post-Report"); } } else { System.out.println("Failed to open the Multi user license page"); } } else { System.out.println("Unable to open the Files and folder page after login"); } driver.quit(); }
From source file:businesscomponents.ReportcomparisonComponents.java
public void storePreReportValues() throws IOException, InterruptedException { String Report = dataTable.getData("General_Data", "ReportName"); oldTab = driver.getWindowHandle();//w w w. j a va2 s.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 . j a va 2s . co 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); } }
From source file:businesscomponents.ReportcomparisonComponents.java
public void openReport() throws InterruptedException { driver.switchTo().frame("TableFrame"); tObj.getCompletedLnk().click();//from ww w .j a va2 s . co m Thread.sleep(2000); driver.switchTo().frame("ifrMainFrame"); String strPreValue = dataTable.getData("General_Data", "ReportName"); driver.findElement(By.id("FilterText")).clear(); driver.findElement(By.id("FilterText")).sendKeys(strPreValue); Thread.sleep(1200); driver.findElement(By.xpath("//input[@value='Apply']")).click(); driver.switchTo().frame("ifrListFrame"); if (reportIterator > 0) { driver.findElement(By.xpath("(.//*[@id='OutputFileName']/a[contains(text(),'" + strPreValue + "') and (contains(text(),'ROI') or contains(text(),'roi'))])[" + (reportIterator + 1) + "]")) .click(); } else { driver.findElement(By.xpath("(.//*[@id='OutputFileName']/a[contains(text(),'" + strPreValue + "') and (contains(text(),'ROI') or contains(text(),'roi'))])[1]")).click(); } Thread.sleep(1200); }
From source file:businesscomponents.ReportcomparisonComponents1.java
public void getPostReportValues() throws InterruptedException { By by = By.id("acFileExplorer"); waitForElement(driver, by, 3000);/*from www. j a v a2s . c om*/ driver.switchTo().frame(driver.findElement(By.id("acFileExplorer"))); WebElement folderFrame = driver.findElement(By.xpath("//frame[@name='main']")); driver.switchTo().frame(folderFrame); driver.findElement(By.xpath("//a[contains(@href,'Sox2015')]")).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); driver.findElement(By.xpath("//a[contains(@href,'/Sox2015/MRF200_SOX15.ROI;1')]")).click(); 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>(); driver.switchTo().defaultContent(); for (int i = 0; i < intPostPageNo; i++) { 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(); page.add(currentReportValues); } Postpages.add(page); }
From source file:businesscomponents.ReportcomparisonComponents1.java
public void completeReportComparison1() throws Exception { Thread.sleep(1000);/*ww w.jav a2s . co m*/ int flagPrepg, flagPostPg; flagPrepg = 0; flagPostPg = 0; String PreURL = dataTable.getData("General_Data", "PreURL"); driver.get(PreURL); tObj.getUserIdTextBox().clear(); tObj.getUserIdTextBox().sendKeys(dataTable.getData("General_Data", "UserId")); tObj.getPasswordTextBox().sendKeys(dataTable.getData("General_Data", "Password")); tObj.getLoginButton().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(1200); // System.out.println("Page title is: " + driver.getTitle()); if (driver.getTitle().contains("Files & Folders")) { String[] foldersName = dataTable.getData("General_Data", "PreReportFolderName").split(";"); int LengthFolder = foldersName.length; for (int folderLoop = 0; folderLoop < foldersName.length - 1; folderLoop++) { driver.switchTo().frame(driver.findElement(By.id("TableFrame"))); driver.switchTo().frame(driver.findElement(By.id("tableFrame"))); if (waitForElement(driver, By.linkText(foldersName[folderLoop]), 1000)) { 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(); } driver.switchTo().frame(driver.findElement(By.id("TableFrame"))); driver.switchTo().frame(driver.findElement(By.id("tableFrame"))); Thread.sleep(4000); final String PreReportName_xpath = "//a[contains(@href,'" + foldersName[(LengthFolder - 1)] + "')]"; int NumberReports = driver.findElements(By.xpath(PreReportName_xpath)).size(); //System.out.println("Number of Reports :" +NumberReports); //reporting for report present or not driver.findElements(By.xpath(PreReportName_xpath)).get(NumberReports - 1).click(); driver.switchTo().defaultContent(); driver.switchTo().frame(driver.findElement(By.id("TableFrame"))); driver.switchTo().frame(driver.findElement(By.id("tableFrame"))); String reportName = dataTable.getData("General_Data", "ReportName"); // Thread.sleep(3000); //if (waitForElement(driver, By.linkText(reportName), 3000)) // { // driver.findElement(By.linkText(reportName)).click(); //driver.findElements(By.xpath(".//*[@id='ItemsTable']//a")).get(0).click(); // int s = driver.findElements(By.xpath(".//*[@id='ItemsTable']//a")).size(); //driver.findElements(By.xpath(".//*[@id='ItemsTable']//a")).get(s-1).click(); ArrayList<String> tab = new ArrayList<String>(driver.getWindowHandles()); driver.switchTo().window(tab.get(1)); // System.out.println("Window Title : " +driver.getTitle()); waitForElement(driver, By.id("toolbarframe"), 4000); driver.switchTo().frame(driver.findElement(By.id("toolbarframe"))); //System.out.println("Switched to frame"); 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()); // System.out.println("value of no_Of_Pages: " +no_Of_Pages); int no_OfPages = Integer.parseInt(no_Of_Pages); //System.out.println("No of pages: " +no_OfPages); driver.switchTo().defaultContent(); driver.switchTo().frame(driver.findElement(By.id("reportframe"))); 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<String> column_Values=new ArrayList<>(); 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++) { 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 { 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"; 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; // System.out.println("Pre data is : " +pre_reportData); //table_data.clear(); 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); //System.out.println("Pre data for page "+l+ " is : " +pre_reportData.get(l)); } page.add(strHeaderVal); driver.switchTo().defaultContent(); driver.switchTo().frame(driver.findElement(By.id("toolbarframe"))); driver.findElement(By.linkText("Next")).click(); driver.switchTo().defaultContent(); waitForElement(driver, By.id("reportframe"), 2000); driver.switchTo().frame(driver.findElement(By.id("reportframe"))); flagPrepg = 0; } pages.add(page); driver.switchTo().window(tab.get(0)); // } // else // { //report.updateTestLog("Report Selection", "Not able to find the report Name", Status.FAIL); // } } 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 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(); } }