List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:com.pentaho.ctools.cdf.require.XactionComponent.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name:/*from w w w .j a v a 2 s . c o m*/ * Reload Sample * Description: * Reload the sample (not refresh page). * Steps: * 1. Click in Code and then click in button 'Try me'. */ @Test public void tc1_PageContent_DisplayTitle() { this.log.info("tc1_PageContent_DisplayTitle"); // Wait for title become visible and with value 'Community Dashboard Framework' wait.until(ExpectedConditions.titleContains("Community Dashboard Framework")); // Wait for visibility of 'VisualizationAPIComponent' wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]"))); // Validate the sample that we are testing is the one assertEquals("Community Dashboard Framework", driver.getTitle()); assertEquals("XactionComponent", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]"))); }
From source file:com.pentaho.ctools.cdf.SchedulePrptComponent.java
License:Apache License
/** * ############################### Test Case 2 ############################### * * Test Case Name:/*from www . j a v a2s . c o m*/ * Create a Schedule * Description: * It is supposed to create a schedule and validate it was created with * specify data and date. * Steps: * 1. Click to create a schedule prpt. * 2. Fill the form and submit * 3. Check for alert. * 4. On Schedule Manager, it is set the schedule. * @throws InterruptedException */ @Test public void tc3_SchedulePrpt_ScheduleCreatedSuccessful() { this.log.info("tc3_SchedulePrpt_ScheduleCreatedSuccessful"); this.bRemoveSchedule = true; String schLocation = "/public"; //Initialize some data SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat sdfDay = new SimpleDateFormat("d"); Date dNow = new Date(); Calendar c = Calendar.getInstance(); c.setTime(dNow); c.add(Calendar.DATE, 1); Date dTomorrow = c.getTime(); c.add(Calendar.DATE, 40); //30th days from today Date d40days = c.getTime(); // ## Step 1 this.elemHelper.FindElement(driver, By.xpath("//span[@id='sampleObject']/button")).click(); // ## Step 2 wait.until(ExpectedConditions.presenceOfElementLocated(By.id("jqistate_basicState"))); //Set schedule name this.elemHelper.FindElement(driver, By.id("nameIn")).clear(); this.elemHelper.FindElement(driver, By.id("nameIn")).sendKeys(this.schNameTc3); //Set schedule location this.elemHelper.FindElement(driver, By.id("locationIn")).clear(); this.elemHelper.FindElement(driver, By.id("locationIn")).sendKeys(schLocation); //Select Monthly Select slRecurrence = new Select(this.elemHelper.FindElement(driver, By.id("recurrId"))); slRecurrence.selectByValue("monthly"); //Select Hour Select slHours = new Select(this.elemHelper.FindElement(driver, By.id("hours"))); slHours.selectByValue("9"); //Select Minutes Select slMinutes = new Select(this.elemHelper.FindElement(driver, By.id("minutes"))); slMinutes.selectByValue("17"); //Select AM/FM Select slAMFM = new Select(this.elemHelper.FindElement(driver, By.id("amPm"))); slAMFM.selectByValue("pm"); //Select Option 'The x y of every month this.elemHelper.FindElement(driver, By.xpath("//div[@id='patternMonth']/input[2]")).click(); //Select Month Select slOccDay = new Select(this.elemHelper.FindElement(driver, By.id("monthOpt1Select"))); slOccDay.selectByValue("1"); //Select Wednesday Select slWeekday = new Select(this.elemHelper.FindElement(driver, By.id("monthOpt2Select"))); slWeekday.selectByValue("3"); //Select Range Of Recurrence //Start - tomorrow this.elemHelper.FindElement(driver, By.id("rangeStartIn")).clear(); this.elemHelper.FindElement(driver, By.id("rangeStartIn")).sendKeys(sdf.format(dTomorrow)); this.elemHelper.Click(driver, By.id("rangeStartIn")); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//table[@class='ui-datepicker-calendar']"))); WebElement dateCalendar = this.elemHelper.FindElement(driver, By.xpath("//table[@class='ui-datepicker-calendar']")); List<WebElement> columns = dateCalendar.findElements(By.tagName("td")); String tomorrowDay = sdfDay.format(dTomorrow); for (WebElement cell : columns) { String strCell = cell.getText(); if (strCell.equals(tomorrowDay)) { cell.findElement(By.linkText(tomorrowDay)).click(); break; } } //End //Select End Date wait.until(ExpectedConditions.elementToBeClickable(By.id("endByRadio"))); this.elemHelper.FindElement(driver, By.id("endByRadio")).click(); this.elemHelper.FindElement(driver, By.id("endByIn")).sendKeys(sdf.format(d40days)); this.elemHelper.FindElement(driver, By.id("endByIn")).click(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//table[@class='ui-datepicker-calendar']"))); WebElement dateCalendar2 = this.elemHelper.FindElement(driver, By.xpath("//table[@class='ui-datepicker-calendar']")); List<WebElement> columns2 = dateCalendar2.findElements(By.tagName("td")); String day = sdfDay.format(d40days); for (WebElement cell2 : columns2) { String strCell2 = cell2.getText(); if (strCell2.equals(day)) { cell2.findElement(By.linkText(day)).click(); break; } } //Submit Form wait.until(ExpectedConditions.elementToBeClickable(By.id("jqi_basicState_buttonOk"))); this.elemHelper.FindElement(driver, By.id("jqi_basicState_buttonOk")).click(); //Wait for the new window. wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("jqistate_mailState"))); wait.until(ExpectedConditions.elementToBeClickable(By.id("jqi_mailState_buttonOk"))); this.elemHelper.FindElement(driver, By.id("jqi_mailState_buttonOk")).click(); // ## Step 3 wait.until(ExpectedConditions.alertIsPresent()); Alert alert = driver.switchTo().alert(); String confirmationMsg = alert.getText(); alert.accept(); assertEquals(confirmationMsg, "Successfully scheduled."); // ## Step 4 //-->Need to check if the schedule was created //Go to home page driver.get(PageUrl.PUC); // NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.xpath("//div[@class='busy-indicator-container waitPopup']")); //Click in Schedule wait.until(ExpectedConditions.titleContains("Pentaho User Console")); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div[@id='pucUserDropDown']/table/tbody/tr/td/div"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//iframe[@id='home.perspective']"))); wait.until(ExpectedConditions .elementToBeClickable(By.xpath("//div[@id='mantle-perspective-switcher']/table/tbody/tr/td[2]"))); this.elemHelper .FindElement(driver, By.xpath("//div[@id='mantle-perspective-switcher']/table/tbody/tr/td[2]")) .click(); WebElement listMenyTr = this.elemHelper.FindElement(driver, By.xpath("//div[@id='customDropdownPopupMajor']/div/div/table/tbody")); List<WebElement> listMenuElementsTrs = listMenyTr.findElements(By.xpath("//td[@class='gwt-MenuItem']")); for (int i = 0; i < listMenuElementsTrs.size(); i++) { WebElement element = listMenuElementsTrs.get(i); if (element.getText().equals("Schedules")) { element.click(); break; } } wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div.workspaceHeading"))); // Now we are in Schedule page List<WebElement> listScheduleTrs = this.elemHelper .FindElement(driver, By.xpath("//table[@id='schedule-table']/tbody")) .findElements(By.tagName("tr")); String scheduleName = ""; String scheduleRepeats = ""; String scheduleSourceFile = ""; String scheduleOuputLocation = ""; String scheduleLastRun = ""; String scheduleNextRun = ""; String scheduleCreatedBy = ""; String scheduleStatus = ""; for (int j = 1; j <= listScheduleTrs.size(); j++) { WebElement elementFirstDiv = this.elemHelper.FindElement(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td/div")); scheduleName = elementFirstDiv.getText(); if (scheduleName.equals(this.schNameTc3)) { scheduleRepeats = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td[2]/div")); scheduleSourceFile = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td[3]/div")); scheduleOuputLocation = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td[4]/div")); scheduleLastRun = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td[5]/div")); scheduleNextRun = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td[6]/div")); scheduleCreatedBy = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td[7]/div")); scheduleStatus = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td[8]/div")); break; } } //Getting the week day of next run String dayOfWeek = ""; if (!scheduleNextRun.isEmpty()) { try { Date dateNextRun = new SimpleDateFormat("yyyy MMM dd HH:mm:ss", Locale.US).parse(scheduleNextRun); dayOfWeek = new SimpleDateFormat("EE", Locale.US).format(dateNextRun); } catch (ParseException pe) { this.log.error(pe.getMessage()); } } assertEquals(this.schNameTc3, scheduleName); assertEquals("The second Wednesday of every month at 21:17:00", scheduleRepeats); assertEquals("/public/Steel Wheels/Widget Library/Report Snippets/InventorybyLine", scheduleSourceFile); assertEquals(schLocation, scheduleOuputLocation); assertEquals("-", scheduleLastRun); assertEquals("Wed", dayOfWeek); assertEquals("admin", scheduleCreatedBy); assertEquals("Normal", scheduleStatus); }
From source file:com.pentaho.ctools.cdf.SchedulePrptComponent.java
License:Apache License
/** * This method will remove all created schedules on the tests. * Note - for a new schedule update code. *//*from w w w.jav a 2 s . co m*/ private void removeAllCreatedSchedules() { this.log.info("removeAllCreatedSchedules"); //Go to home page driver.get(PageUrl.PUC); // NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.xpath("//div[@class='busy-indicator-container waitPopup']")); //Click in Schedule wait.until(ExpectedConditions.titleContains("Pentaho User Console")); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div[@id='pucUserDropDown']/table/tbody/tr/td/div"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//iframe[@id='home.perspective']"))); wait.until(ExpectedConditions .elementToBeClickable(By.xpath("//div[@id='mantle-perspective-switcher']/table/tbody/tr/td[2]"))); this.elemHelper .FindElement(driver, By.xpath("//div[@id='mantle-perspective-switcher']/table/tbody/tr/td[2]")) .click(); WebElement listMenyTr = this.elemHelper.FindElement(driver, By.xpath("//div[@id='customDropdownPopupMajor']/div/div/table/tbody")); List<WebElement> listMenuElementsTrs = listMenyTr.findElements(By.xpath("//td[@class='gwt-MenuItem']")); for (int i = 0; i < listMenuElementsTrs.size(); i++) { WebElement element = listMenuElementsTrs.get(i); if (element.getText().equals("Schedules")) { element.click(); break; } } wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div.workspaceHeading"))); // Now we are in Schedule page Boolean someThingToDelete = true; int listElements = 0; int listElementsPrevious = -1; while (someThingToDelete) { someThingToDelete = false; List<WebElement> listScheduleTrs = this.elemHelper .FindElement(driver, By.xpath("//table[@id='schedule-table']/tbody")) .findElements(By.tagName("tr")); listElements = listScheduleTrs.size(); //The new list must be different from previous list while (listElements == listElementsPrevious) { listScheduleTrs = this.elemHelper .FindElement(driver, By.xpath("//table[@id='schedule-table']/tbody")) .findElements(By.tagName("tr")); listElements = listScheduleTrs.size(); } for (int j = 1; j <= listElements; j++) { WebElement elementFirstDiv = this.elemHelper.FindElement(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]/td/div")); if (elementFirstDiv.getText().equals(this.schNameTc3)) { elementFirstDiv.click(); //Select the row //Wait for row to be selected for (int t = 0; t < 100; t++) { WebElement elementRow = this.elemHelper.FindElement(driver, By.xpath("//table[@id='schedule-table']/tbody/tr[" + j + "]")); if (elementRow.getAttribute("class").contains("cellTableSelectedRow")) { break; } } //Click to remove the schedule item (the selected row) this.elemHelper.Click(driver, By.cssSelector("img.gwt-Image.pentaho-deletebutton")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@class='pentaho-dialog']")); this.elemHelper.Click(driver, By.id("okButton")); this.elemHelper.WaitForElementInvisibility(driver, By.xpath("//div[@class='pentaho-dialog']")); someThingToDelete = true; //Continue checking if there is something to delete break; } } listElementsPrevious = listElements; } }
From source file:com.pentaho.ctools.cdf.TableComponent.java
License:Apache License
/** * ############################### Test Case 3 ############################### * * Test Case Name://from w w w.ja v a 2 s . co m * Check Paging * Description: * User has the possibility to navigate between pages, and new date shall * be displayed. * Steps: * 1. Check the data in first page is correct. * 2. Go to the next page and check the data. * 3. Go to the end page and check the data. * 4. Go to the first page and check the data. */ @Test public void tc3_Paging_NavigateBetweenPages() { this.log.info("tc3_Paging_NavigateBetweenPages"); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_length"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_filter"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_info"))); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("sampleObjectTable_paginate"))); //## Step 1 assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 2 //Where we press NEXT WebElement page2 = this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")); assertNotNull(page2); page2.sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']"))); assertEquals("Showing 11 to 20 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Danish Wholesale Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("145,042", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("174,140", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Extreme Desk Decorations, Ltd", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Handji Gifts& Co", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("115,499", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 3 //Where we press 5 WebElement page5 = this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5]")); assertNotNull(page5); page5.sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5][@class='paginate_button current']"))); assertEquals("Showing 41 to 50 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Suominen Souveniers", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("113,961", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("160,010", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Toys of Finland, Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Vitachrome Inc.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("88,041", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 4 this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[4][@class='paginate_button current']"))); this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']"))); this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']"))); this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_previous']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[@class='paginate_button current']"))); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); }
From source file:com.pentaho.ctools.cdf.TableComponent.java
License:Apache License
/** * ############################### Test Case 4 ############################### * * Test Case Name:/*w w w . j av a 2 s. c om*/ * Sort * Description: * Testing the sort on Customer and Sales, and when user is not in the * first page. * Steps: * 1. Sort in Customer (Desc) * 2. Sort in Sales (Asc) * 3. Page to the third page * 4. Sort in Sales (Desc) * 5. Go to the next page and check the data. * 6. Go to the end page and check the data. * 7. Go to the first page and check the data. */ @Test public void tc4_Sort_ElementsAreSort() { this.log.info("tc4_Sort_ElementsAreSort"); //## Step 1 wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[@class='column0 string sorting_asc']"))); this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th")).click(); //Set to DESC wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[@class='column0 string sorting_desc']"))); //Check Data assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']"))); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Vitachrome Inc.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("88,041", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("118,008", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertTrue(this.elemHelper .WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td")) .contains("Toms")); assertEquals("Suominen Souveniers", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("113,961", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 2 this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[2]")).click(); //Sort Sales to ASC wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[2][@class='column1 numeric sorting_asc']"))); //Check Data assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']"))); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Collectable Mini Designs Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("87,489", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("88,805", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertTrue(this.elemHelper .WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td")) .contains("Toms")); assertEquals("100,307", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 3 WebElement page3 = this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3]")); assertNotNull(page3); page3.sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']"))); //Check Data assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']"))); assertEquals("Showing 21 to 30 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Handji Gifts& Co", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("115,499", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("117,714", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Corrida Auto Replicas, Ltd", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Scandinavian Gift Ideas", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("134,259", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 4 this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[2]")).click(); //Sort Sales to DESC wait.until(ExpectedConditions.visibilityOfElementLocated(By .xpath("//table[@id='sampleObjectTable']/thead/tr/th[2][@class='column1 numeric sorting_desc']"))); //Check Data assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']"))); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Euro+ Shopping Channel", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("912,294", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Down Under Souveniers, Inc", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Kelly's Gift Shop", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("158,345", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 5 WebElement page2 = this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")); assertNotNull(page2); page2.sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']"))); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']"))); assertEquals("Showing 11 to 20 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("AV Stores, Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("157,808", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("151,571", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Danish Wholesale Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Reims Collectables", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("135,043", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 6 this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[3][@class='paginate_button current']"))); this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[4][@class='paginate_button current']"))); this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5][@class='paginate_button current']"))); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5][@class='paginate_button current']"))); assertEquals("Showing 41 to 50 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertTrue(this.elemHelper .WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td")) .contains("Toms")); assertEquals("100,307", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("98,496", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Collectable Mini Designs Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("87,489", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 7 WebElement page1 = this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")); assertNotNull(page1); page1.sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']"))); //Check Data assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1][@class='paginate_button current']"))); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Euro+ Shopping Channel", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("912,294", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Down Under Souveniers, Inc", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Kelly's Gift Shop", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("158,345", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //reset to initial state this.elemHelper.FindElement(driver, By.xpath("//table[@id='sampleObjectTable']/thead/tr/th")).click(); //Set Customers to ASC wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//table[@id='sampleObjectTable']/thead/tr/th[@class='column0 string sorting_asc']"))); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); }
From source file:com.pentaho.ctools.cdf.TableComponent.java
License:Apache License
/** * ############################### Test Case 5 ############################### * * Test Case Name:/* ww w . j a v a 2 s . c om*/ * Display Entries * Description: * When select the number of entries, the table displayed the number of * entries selected with data. * Steps: * 1. Select 25 and paging * 2. Select 50 (no paging) */ @Test public void tc5_DisplayEntries_DisplayTheNumberOfEntriesSelected() { this.log.info("tc5_DisplayEntries_DisplayTheNumberOfEntriesSelected"); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //## Step 1 Select displayEntries = new Select(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_length']/label/select"))); displayEntries.selectByValue("25"); assertEquals("Showing 1 to 25 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //11 to 25 assertEquals("Dragon Souveniers, Ltd.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[14]/td"))); assertEquals("172,990", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[14]/td[2]"))); assertEquals("98,924", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[17]/td[2]"))); assertEquals("Handji Gifts& Co", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[20]/td"))); assertEquals("La Corne D'abondance, Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[25]/td"))); assertEquals("97,204", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[25]/td[2]"))); //## Step 2 displayEntries = new Select(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_length']/label/select"))); displayEntries.selectByValue("50"); assertEquals("Showing 1 to 50 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //11 to 25 assertEquals("Dragon Souveniers, Ltd.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[14]/td"))); assertEquals("172,990", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[14]/td[2]"))); assertEquals("98,924", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[17]/td[2]"))); assertEquals("Handji Gifts& Co", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[20]/td"))); assertEquals("La Corne D'abondance, Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[25]/td"))); assertEquals("97,204", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[25]/td[2]"))); //26 to 50 assertEquals("Muscle Machine Inc", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[31]/td"))); assertEquals("197,737", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[31]/td[2]"))); assertEquals("151,571", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[39]/td[2]"))); assertEquals("Toys of Finland, Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[46]/td"))); assertEquals("Vitachrome Inc.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[50]/td"))); assertEquals("88,041", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[50]/td[2]"))); //Reset display to 10 displayEntries = new Select(this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_length']/label/select"))); displayEntries.selectByValue("10"); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[5]"))); assertEquals("Showing 1 to 10 of 50 entries", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("200,995", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Baane Mini Imports", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("94,016", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); }
From source file:com.pentaho.ctools.cdf.TableComponent.java
License:Apache License
/** * ############################### Test Case 6 ############################### * * Test Case Name:// w ww. j a v a2 s .c o m * Search Engine * Description: * When search for something the table is refresh with the contents * searched. * Steps: * 1. Search for 'Co.' (Check paging, display entries, sort) * 2. Search for 'Euro' (Check paging, display entries, sort) * 3. Search for 'TODO' (no result) */ @Test public void tc6_SearchEngine_TableDisplayedContentSearch() { this.log.info("tc6_SearchEngine_TableDisplayedContentSearch"); //## Step 1 this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input")) .sendKeys("Co."); assertEquals("Showing 1 to 10 of 13 entries (filtered from 50 total entries)", this.elemHelper .WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isDisplayed()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isEnabled()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isDisplayed()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isEnabled()); //check paging 1 and 2 assertTrue(this.elemHelper .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isEnabled()); assertTrue(this.elemHelper .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isDisplayed()); assertTrue(this.elemHelper .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2]")).isEnabled()); assertTrue(this.elemHelper .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2]")).isDisplayed()); assertEquals("Amica Models & Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("94,117", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); assertEquals("157,808", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); assertEquals("Cruz & Sons Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[6]/td"))); assertEquals("Saveley & Henriot, Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td"))); assertEquals("142,874", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[10]/td[2]"))); //Click Next this.elemHelper.FindElement(driver, By.xpath("//a[@id='sampleObjectTable_next']")).sendKeys(Keys.ENTER); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2][@class='paginate_button current']"))); assertEquals("Souveniers And Things Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[1]/td"))); assertEquals("Toys of Finland, Co.", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td"))); assertEquals("111,250", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr[3]/td[2]"))); //## Step 2 this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input")).clear(); this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input")) .sendKeys("Euro"); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isDisplayed()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isEnabled()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isDisplayed()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isEnabled()); assertTrue(this.elemHelper .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isEnabled()); assertTrue(this.elemHelper .FindElement(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]")).isDisplayed()); assertTrue(this.elemHelper.WaitForElementNotPresent(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[2]"), 2)); assertEquals("Showing 1 to 1 of 1 entries (filtered from 50 total entries)", this.elemHelper .WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("Euro+ Shopping Channel", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); assertEquals("912,294", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td[2]"))); //## Step 3 this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input")).clear(); this.elemHelper.FindElement(driver, By.xpath("//div[@id='sampleObjectTable_filter']/label/input")) .sendKeys("TODO"); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isDisplayed()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_previous")).isEnabled()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isDisplayed()); assertTrue(this.elemHelper.FindElement(driver, By.id("sampleObjectTable_next")).isEnabled()); assertTrue(this.elemHelper.WaitForElementNotPresent(driver, By.xpath("//div[@id='sampleObjectTable_paginate']/span/a[1]"), 2)); assertEquals("Showing 0 to 0 of 0 entries (filtered from 50 total entries)", this.elemHelper .WaitForElementPresentGetText(driver, By.xpath("//div[@id='sampleObjectTable_info']"))); assertEquals("No matching records found", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table[@id='sampleObjectTable']/tbody/tr/td"))); }
From source file:com.pentaho.ctools.cdf.TextInputComponent.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name://from ww w . j a v a2 s. co m * Reload Sample * Description: * Reload the sample (not refresh page). * Steps: * 1. Click in Code and then click in button 'Try me'. */ @Test public void tc1_PageContent_DisplayTitle() { // Wait for title become visible and with value 'Community Dashboard Framework' wait.until(ExpectedConditions.titleContains("Community Dashboard Framework")); // Wait for visibility of 'VisualizationAPIComponent' wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]"))); // Validate the sample that we are testing is the one assertEquals("Community Dashboard Framework", driver.getTitle()); assertEquals("TextInputComponent", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]"))); }
From source file:com.pentaho.ctools.cdf.XactionComponent.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name://from w w w. j a va2s .c o m * Reload Sample * Description: * Reload the sample (not refresh page). * Steps: * 1. Click in Code and then click in button 'Try me'. */ @Test public void tc1_PageContent_DisplayTitle() { // Wait for title become visible and with value 'Community Dashboard Framework' wait.until(ExpectedConditions.titleContains("Community Dashboard Framework")); // Wait for visibility of 'VisualizationAPIComponent' wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]"))); // Validate the sample that we are testing is the one assertEquals("Community Dashboard Framework", driver.getTitle()); assertEquals("XactionComponent", this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='dashboardContent']/div/div/div/h2/span[2]"))); }
From source file:com.pentaho.ctools.utils.ElementHelper.java
License:Apache License
/** * This method pretends to check if the element is present, if it doesn't * then don't wait, if element is present, wait for its invisibility. * * @param driver/* www . java 2 s. c o m*/ * @param locator */ public WebElement WaitForElementVisibility(WebDriver driver, By locator) { this.log.debug("WaitForElementVisibility::Enter"); this.log.debug("Locator: " + locator.toString()); WebElement element = null; List<WebElement> elements = null; Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(30, TimeUnit.SECONDS) .pollingEvery(50, TimeUnit.MILLISECONDS).ignoring(StaleElementReferenceException.class); driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); try { elements = driver.findElements(locator); if (elements.size() > 0) { // wait for element to appear element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator)); this.log.debug("Get element visible."); } else { this.log.warn("No elements found!"); } } catch (Exception e) { this.log.warn("Something went wrong searching for vi: " + locator.toString()); this.log.catching(e); } // ------------ ALWAYS REQUIRE TO SET THE DEFAULT VALUE -------------------- // when set a new implicitlyWait timeout, we have to set the default // in order to not destroy other invocations of findElement ('WebDriver'). driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); this.log.debug("WaitForElementVisibility::Exit"); return element; }