List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated
public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator)
From source file:com.pentaho.ctools.cdf.ExecuteXactionComponent.java
License:Apache License
/** * ############################### Test Case 3 ############################### * * Test Case Name:/*from ww w. j a v a2 s . c om*/ * Execute Xacion * Description: * We pretend validate the generated chart (in an image) and if the image * has a valid url. * Steps: * 1. Click to generate chart * 2. Check if a chart was generated * 3. Check the http request for the image generated */ @Test public void tc3_PressToGenerateChart_ChartIsDisplayed() { // ## Step 1 final String buttonName = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//button/span")); assertEquals("Execute XAction", buttonName); //Click in button this.elemHelper.FindElement(driver, By.xpath("//button")).click(); // ## Step 1 wait.until(ExpectedConditions.presenceOfElementLocated(By.id("fancybox-content"))); driver.switchTo().frame("fancybox-frame"); //Check the title final String chartTitle = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table/tbody/tr/td")); assertEquals("Action Successful", chartTitle); //Check for the displayed image final WebElement xactionElement = this.elemHelper.FindElement(driver, By.cssSelector("img")); assertNotNull(xactionElement); final String attrSrc = xactionElement.getAttribute("src"); final String attrWidth = xactionElement.getAttribute("width"); final String attrHeight = xactionElement.getAttribute("height"); assertTrue(attrSrc.startsWith(baseUrl + "getImage?image=tmp_chart_admin-")); assertEquals(attrWidth, "500"); assertEquals(attrHeight, "600"); // ## Step 3 try { final URL url = new URL(attrSrc); final URLConnection connection = url.openConnection(); connection.connect(); assertEquals(HttpStatus.SC_OK, ((HttpURLConnection) connection).getResponseCode()); } catch (final Exception ex) { this.log.error(ex.getMessage()); } //Close pop-up window driver.switchTo().defaultContent(); this.elemHelper.FindElement(driver, By.id("fancybox-close")).click(); this.elemHelper.WaitForElementInvisibility(driver, By.id("fancybox-content")); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//button"))); }
From source file:com.pentaho.ctools.cdf.require.ExecutePrptComponent.java
License:Apache License
/** * ############################### Test Case 3 ############################### * * Test Case Name:// w ww . j av a2s. c o m * Select HTML and PDF (content type) * Description: * The test case pretends validate the result when change for option HTML * and PDF for content-type. * Steps: * 1. Check the contents presented */ @Test public void tc3_CheckDisplayPage_DataIsDisplayedAsExpected() { this.log.info("tc3_CheckDisplayPage_DataIsDisplayedAsExpected"); /* * ## Step 1 */ String buttonText = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//button/span")); assertEquals("Execute Prpt", buttonText); this.elemHelper.FindElement(driver, By.xpath("//button/span")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.id("fancybox-content"))); //Move to iframe WebElement elemIFrame = this.elemHelper.FindElement(driver, By.xpath("//iframe")); String attrId = elemIFrame.getAttribute("id"); driver.switchTo().frame(attrId); //Wait for glasspane display and disable this.elemHelper.WaitForElementPresence(driver, By.id("glasspane"), 5); this.elemHelper.WaitForElementInvisibility(driver, By.id("glasspane")); //Check presence of tool bar elements assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='toolbar']/div"))); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='toolbar']/div[2]"))); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@id='toolbar']/span"))); //Check the Product Name and Output Type WebElement elemtLine = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.cssSelector("div.parameter-label"), 45); assertNotNull(elemtLine); String prodName = this.elemHelper.WaitForElementPresentGetText(driver, By.cssSelector("div.parameter-label")); assertEquals("Line", prodName); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//td/div/div[2]/select"))); String outputTypeName = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@class='parameter']/div[2]/select/../../div")); assertEquals("Output Type", outputTypeName); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//div[@class='parameter']/div[2]/select"))); //Check for View Report button if (pentahoReleaseVersion.equalsIgnoreCase(ConfigurationSettings.PENTAHO_RELEASE_VERSION_6X)) { String buttonName = this.elemHelper.WaitForElementPresentGetText(driver, By.cssSelector("button.pentaho-button")); assertEquals("View Report", buttonName); } else { String buttonName = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//button/span")); assertEquals("View Report", buttonName); } //Check the generated image this.elemHelper.WaitForElementPresence(driver, By.cssSelector("iframe#reportContent")); WebDriver driverReportContent = driver.switchTo().frame("reportContent"); WebElement elemReport = this.elemHelper.WaitForElementPresenceAndVisible(driverReportContent, By.xpath("//tbody/tr")); assertNotNull(elemReport); this.elemHelper.WaitForTextPresence(driverReportContent, By.xpath("//tbody/tr"), "LINE: Classic Cars"); String strTitle = this.elemHelper.WaitForElementPresentGetText(driverReportContent, By.xpath("//tbody/tr")); assertEquals("LINE: Classic Cars", strTitle); this.elemHelper.WaitForTextPresence(driverReportContent, By.xpath("//tbody/tr[3]/td"), "Autoart Studio Design"); String strCompany = this.elemHelper.WaitForElementPresentGetText(driverReportContent, By.xpath("//tbody/tr[3]/td")); assertEquals("Autoart Studio Design", strCompany); this.elemHelper.WaitForTextPresence(driverReportContent, By.xpath("//tbody/tr[5]/td[3]/a"), "1958 Chevy Corvette Limited Edition"); String strValue = this.elemHelper.WaitForElementPresentGetText(driverReportContent, By.xpath("//tbody/tr[5]/td[3]/a")); assertEquals("1958 Chevy Corvette Limited Edition", strValue); String strHref = this.elemHelper.GetAttribute(driverReportContent, By.xpath("//tbody/tr[5]/td[3]/a"), "href"); assertEquals("http://images.google.com/images?q=1958%20Chevy%20Corvette%20Limited%20Edition", strHref); }
From source file:com.pentaho.ctools.cdf.require.ExecuteXactionComponent.java
License:Apache License
/** * ############################### Test Case 3 ############################### * * Test Case Name:/*from w w w . j a v a 2 s. c o m*/ * Execute Xacion * Description: * We pretend validate the generated chart (in an image) and if the image * has a valid url. * Steps: * 1. Click to generate chart * 2. Check if a chart was generated * 3. Check the http request for the image generated */ @Test public void tc3_PressToGenerateChart_ChartIsDisplayed() { this.log.info("tc3_PressToGenerateChart_ChartIsDisplayed"); /* * ## Step 1 */ final String buttonName = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//button/span")); assertEquals("Execute XAction", buttonName); //Click in button this.elemHelper.FindElement(driver, By.xpath("//button")).click(); // ## Step 1 wait.until(ExpectedConditions.presenceOfElementLocated(By.id("fancybox-content"))); driver.switchTo().frame("fancybox-frame"); //Check the title final String chartTitle = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//table/tbody/tr/td")); assertEquals("Action Successful", chartTitle); //Check for the displayed image final WebElement xactionElement = this.elemHelper.FindElement(driver, By.cssSelector("img")); assertNotNull(xactionElement); final String attrSrc = xactionElement.getAttribute("src"); final String attrWidth = xactionElement.getAttribute("width"); final String attrHeight = xactionElement.getAttribute("height"); assertTrue(attrSrc.startsWith(baseUrl + "getImage?image=tmp_chart_admin-")); assertEquals(attrWidth, "500"); assertEquals(attrHeight, "600"); // ## Step 3 try { final URL url = new URL(attrSrc); final URLConnection connection = url.openConnection(); connection.connect(); assertEquals(HttpStatus.SC_OK, ((HttpURLConnection) connection).getResponseCode()); } catch (final Exception ex) { this.log.error(ex.getMessage()); } //Close pop-up window driver.switchTo().defaultContent(); this.elemHelper.FindElement(driver, By.id("fancybox-close")).click(); this.elemHelper.WaitForElementInvisibility(driver, By.id("fancybox-content")); assertNotNull(this.elemHelper.FindElement(driver, By.xpath("//button"))); }
From source file:com.pentaho.ctools.cdf.require.SchedulePrptComponent.java
License:Apache License
/** * ############################### Test Case 2 ############################### * * Test Case Name://w ww . ja va 2 s .com * 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("//div[@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.Click(driver, By.xpath("//div[@id='patternMonth']/input[2]")); //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)); 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)); 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.require.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 . j av a 2 s . c o 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.SchedulePrptComponent.java
License:Apache License
/** * ############################### Test Case 2 ############################### * * Test Case Name:/*from w w w. j av a 2 s .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. j a va2s.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.Priyanka.junitProgramsTests.alertNewWindow.java
@Test public void handleAlertWindow() { driver.navigate().to("http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"); WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("head > title"))); Assert.assertEquals(driver.getTitle(), "Java SE Development Kit 8 - Downloads"); driver.findElement(By.xpath("//*[@id='jdk-8u91-oth-JPRXXXjdk-8u91-windows-x64.exe']")).click(); System.out.println("Driver current handle before: " + driver.getWindowHandle()); Alert alertObj = driver.switchTo().alert(); Assert.assertEquals(alertObj.getText(), "Sorry, you must accept the License Agreement before downloading."); System.out.println("Driver current handle after: " + driver.getWindowHandle()); alertObj.accept();//from ww w .j av a2 s .c o m driver.findElement(By.cssSelector("[onclick='acceptAgreement(window.self, \\'jdk-8u91-oth-JPR\\');']")) .click(); driver.findElement(By.xpath("//*[@id='jdk-8u91-oth-JPRXXXjdk-8u91-windows-x64.exe']")).click(); }
From source file:com.Priyanka.junitProgramsTests.alertNewWindow.java
@Test public void switchBackAndForthWindows() { driver.navigate().to("https://hangouts.google.com/"); driver.findElement(By.cssSelector("[aria-label='Start video call']")).click(); String parentWindow = driver.getWindowHandle(); for (String windowHandle : driver.getWindowHandles()) { if (!windowHandle.equals(parentWindow)) { driver.switchTo().window(windowHandle); }//w w w . j a va 2s.c o m } Assert.assertTrue(driver.getCurrentUrl().contains("https://accounts.google.com/ServiceLogin")); driver.findElement(By.name("Email")).sendKeys("priyankamg.test"); driver.findElement(By.cssSelector("#next")).click(); WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#Passwd"))); driver.findElement(By.xpath("//input[@id='PersistentCookie']")).click(); driver.findElement(By.name("Passwd")).sendKeys("karu5%99"); driver.findElement(By.cssSelector("#signIn")).click(); driver.close(); driver.switchTo().window(parentWindow); }
From source file:com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.java
License:Open Source License
@SuppressWarnings("unchecked") public void load(QAFExtendedWebElement... elements) { if (elements != null) { for (QAFExtendedWebElement element : elements) { final By by = element.getBy(); element.setId(//from www .j a va 2 s .c o m ((QAFExtendedWebElement) new QAFWebDriverWait(this) .ignore(NoSuchElementException.class, StaleElementReferenceException.class, RuntimeException.class) .until(ExpectedConditions.presenceOfElementLocated(by))).getId()); } } }