예제 #1
0
 private void TypesOfSchool() throws IOException {
   // Click Type of School
   driver.findElement(By.cssSelector("strong")).click();
   // Click Private
   driver.findElement(By.id("edit-public-private-private")).click();
   // Move School Size Slider
   // TODO Slider not working properly
   WebElement Slider1 = driver.findElement(By.id("population_jq_slider"));
   Actions moveSlider1 = new Actions(driver);
   Action action1 = moveSlider1.dragAndDropBy(Slider1, 0, 10).build();
   action1.perform();
   // Select Religious Affiliation
   new Select(driver.findElement(By.id("edit-religious-affiliation")))
       .selectByVisibleText("Church of Christ");
   // Move Tuition Range Slider
   // TODO Slider not working properly
   WebElement Slider2 = driver.findElement(By.id("tuition_range_jq_slider"));
   Actions moveSlider2 = new Actions(driver);
   Action action2 = moveSlider2.dragAndDropBy(Slider2, 0, 10).build();
   action2.perform();
   // Click Apply
   driver.findElement(By.id("edit-type-of-school-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
  @Override
  public void mouseMoveAt(String locator, String coordString) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    if (coordString.contains(",")) {
      String[] coords = coordString.split(",");

      int x = GetterUtil.getInteger(coords[0]);
      int y = GetterUtil.getInteger(coords[1]);

      actions.moveToElement(webElement, x, y);
      actions.clickAndHold(webElement);
    } else {
      actions.moveToElement(webElement);
      actions.clickAndHold(webElement);
    }

    Action action = actions.build();

    action.perform();
  }
  @Override
  public void keyUp(String locator, String keySequence) {
    WebElement webElement = getWebElement(locator);

    if (keySequence.startsWith("\\")) {
      int index = GetterUtil.getInteger(keySequence.substring(1));

      Keys keys = _keysArray[index];

      if ((index >= 48) && (index <= 90)) {
        webElement.sendKeys(StringPool.ASCII_TABLE[index]);
      } else if ((index == 16) || (index == 17) || (index == 18)) {
        WrapsDriver wrapsDriver = (WrapsDriver) webElement;

        WebDriver webDriver = wrapsDriver.getWrappedDriver();

        Actions actions = new Actions(webDriver);

        actions.keyUp(webElement, keys);

        Action action = actions.build();

        action.perform();
      } else {
        webElement.sendKeys(keys);
      }
    } else {
      webElement.sendKeys(keySequence);
    }
  }
  @Override
  public void clickAt(String locator, String coordString) {
    if (locator.contains("x:")) {
      String url = getHtmlNodeHref(locator);

      open(url);
    } else {
      WebElement webElement = getWebElement(locator);

      if (coordString.contains(",")) {
        WrapsDriver wrapsDriver = (WrapsDriver) webElement;

        WebDriver webDriver = wrapsDriver.getWrappedDriver();

        Actions actions = new Actions(webDriver);

        String[] coords = coordString.split(",");

        int x = GetterUtil.getInteger(coords[0]);
        int y = GetterUtil.getInteger(coords[1]);

        actions.moveToElement(webElement, x, y);
        actions.click();

        Action action = actions.build();

        action.perform();
      } else {
        webElement.click();
      }
    }
  }
예제 #5
0
 /**
  * Focus on the Element(WebElement)
  *
  * @return Parent instance
  */
 public ParentPanel focus() {
   Dimension size = getWebElement().getSize(); // for scroll to object
   logAction(this, getParentClassName(), "focus");
   Actions builder = new Actions(getDriver());
   org.openqa.selenium.interactions.Action focus =
       builder.moveToElement(getWebElement(), size.width / 2, size.height / 2).build();
   focus.perform();
   return parent;
 }
예제 #6
0
 /**
  * A convenience method that performs click at the location of the source element
  *
  * @param xOffset - horizontal move offset.
  * @param yOffset - vertical move offset.
  * @return Parent instance
  */
 public ParentPanel clickBy(int xOffset, int yOffset) {
   doJAction(
       format(
           "click element:  horizontal move offset- %dpx; vertical move offset- %dpx",
           xOffset, yOffset),
       () -> {
         Actions builder = new Actions(getDriver());
         Action click = builder.moveToElement(getWebElement(), xOffset, yOffset).click().build();
         click.perform();
       });
   return parent;
 }
예제 #7
0
  /**
   * A convenience method that performs click-and-hold at the location of the source element, moves
   * by a given offset, then releases the mouse.
   *
   * @param xOffset - horizontal move offset.
   * @param yOffset - vertical move offset.
   * @return Parent instance
   */
  public ParentPanel dragAndDropBy(int xOffset, int yOffset) {
    logAction(
        this,
        getParentClassName(),
        format(
            "Drag and drop element: horizontal move offset - %dpx; vertical move offset - %dpx",
            xOffset, yOffset));

    Actions builder = new Actions(getDriver());

    Action dragAndDropBy = builder.dragAndDropBy(getWebElement(), xOffset, yOffset).build();
    dragAndDropBy.perform();
    return parent;
  }
예제 #8
0
  @Test
  @Use(
      field = "booleanValue",
      booleans = {false, true})
  public void testShowFooter() {
    setCurrentDateWithCalendarsTodayButtonAction.perform();
    calendarAttributes.set(CalendarAttributes.showFooter, booleanValue);
    PopupFooterControls proxiedFooterControls = calendar.openPopup().getProxiedFooterControls();
    if (booleanValue) {
      assertListOfWebElementsVisible(
          Arrays.asList(
              proxiedFooterControls.getApplyButtonElement(),
              proxiedFooterControls.getCleanButtonElement(),
              proxiedFooterControls.getTimeEditorOpenerElement(),
              proxiedFooterControls.getTodayButtonElement()));

    } else {
      assertListOfWebElementsNotVisible(
          Arrays.asList(
              proxiedFooterControls.getApplyButtonElement(),
              proxiedFooterControls.getCleanButtonElement(),
              proxiedFooterControls.getTimeEditorOpenerElement(),
              proxiedFooterControls.getTodayButtonElement()));
    }
  }
  @Override
  public void doubleClick(String locator) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    actions.doubleClick(webElement);

    Action action = actions.build();

    action.perform();
  }
  @Test
  @Templates("plain")
  public void testLocale() {
    String locale = "ru";
    calendarAttributes.set(CalendarAttributes.locale, locale);
    DayPicker dayPicker = popupCalendar.openPopup().getDayPicker();
    List<String> weekDayShortNames = dayPicker.getWeekDayShortNames();
    List<String> expectedShortNames = Arrays.asList("Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб");
    assertEquals(weekDayShortNames, expectedShortNames);

    setCurrentDateWithCalendarsTodayButtonAction.perform();
    DateTime parsedDateTime =
        dateTimeFormatter
            .withLocale(new Locale(locale))
            .parseDateTime(popupCalendar.getInput().getStringValue());

    assertEquals(
        parsedDateTime.getDayOfMonth(),
        todayMidday.getDayOfMonth(),
        "Input doesn't contain selected date.");
    assertEquals(
        parsedDateTime.getMonthOfYear(),
        todayMidday.getMonthOfYear(),
        "Input doesn't contain selected date.");
    assertEquals(
        parsedDateTime.getYear(), todayMidday.getYear(), "Input doesn't contain selected date.");
  }
 @Test
 public void testValueChangeListener() {
   setCurrentDateWithCalendarsTodayButtonAction.perform();
   page.assertListener(
       PhaseId.PROCESS_VALIDATIONS,
       "value changed: null -> " + popupCalendar.getInput().getStringValue());
 }
  @Override
  public void mouseRelease() {
    WebElement bodyWebElement = getWebElement("//body");

    WrapsDriver wrapsDriver = (WrapsDriver) bodyWebElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    actions.release();

    Action action = actions.build();

    action.perform();
  }
  @Override
  public void mouseDown(String locator) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    actions.moveToElement(webElement);
    actions.clickAndHold(webElement);

    Action action = actions.build();

    action.perform();
  }
  @Override
  public void mouseOut(String locator) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    actions.moveToElement(webElement);
    actions.moveByOffset(10, 10);

    Action action = actions.build();

    action.perform();
  }
예제 #15
0
 @Test
 @RegressionTest("https://issues.jboss.org/browse/RF-10821")
 public void testImmediate() {
   calendarAttributes.set(CalendarAttributes.immediate, Boolean.TRUE);
   setCurrentDateWithCalendarsTodayButtonAction.perform();
   page.assertListener(
       PhaseId.APPLY_REQUEST_VALUES, "value changed: null -> " + calendar.getInputValue());
   page.assertPhases(PhaseId.ANY_PHASE);
 }
  @Override
  public void dragAndDropToObject(
      String locatorOfObjectToBeDragged, String locatorOfDragDestinationObject) {

    WebElement objectToBeDraggedWebElement = getWebElement(locatorOfObjectToBeDragged);

    WrapsDriver wrapsDriver = (WrapsDriver) objectToBeDraggedWebElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    WebElement dragDestinationObjectWebElement = getWebElement(locatorOfDragDestinationObject);

    actions.dragAndDrop(objectToBeDraggedWebElement, dragDestinationObjectWebElement);

    Action action = actions.build();

    action.perform();
  }
  @Test
  public void testDatePattern() {
    String pattern = "hh:mm:ss a MMMM d, yyyy";
    calendarAttributes.set(CalendarAttributes.datePattern, pattern);

    setCurrentDateWithCalendarsTodayButtonAction.perform();
    String calendarInputText = popupCalendar.getInput().getStringValue();
    dateTimeFormatter = DateTimeFormat.forPattern(pattern);
    try {
      DateTime dt = dateTimeFormatter.parseDateTime(calendarInputText);
      assertEquals(dt.getDayOfMonth(), todayMidday.getDayOfMonth());
      assertEquals(dt.getMonthOfYear(), todayMidday.getMonthOfYear());
      assertEquals(dt.getYear(), todayMidday.getYear());
    } catch (IllegalArgumentException ex) {
      fail(ex.getMessage());
    }
  }
 @Test
 @UseWithField(field = "booleanValue", valuesFrom = FROM_FIELD, value = "booleans")
 public void testShowApplyButton() {
   calendarAttributes.set(CalendarAttributes.showApplyButton, booleanValue);
   PopupFooterControls fc = popupCalendar.openPopup().getFooterControls();
   if (booleanValue) {
     assertVisible(fc.getApplyButtonElement());
   } else {
     assertNotVisible(fc.getApplyButtonElement());
     setCurrentDateWithCalendarsTodayButtonAction.perform();
     DateTime inputTime =
         dateTimeFormatter.parseDateTime(popupCalendar.getInput().getStringValue());
     assertEquals(inputTime.getDayOfMonth(), todayMidday.getDayOfMonth());
     assertEquals(inputTime.getMonthOfYear(), todayMidday.getMonthOfYear());
     assertEquals(inputTime.getYear(), todayMidday.getYear());
   }
 }
예제 #19
0
 @Test
 @Use(
     field = "booleanValue",
     booleans = {false, true})
 public void testShowApplyButton() {
   calendarAttributes.set(CalendarAttributes.showApplyButton, booleanValue);
   PopupFooterControls proxiedFooterControls = calendar.openPopup().getProxiedFooterControls();
   if (booleanValue) {
     assertVisible(proxiedFooterControls.getApplyButtonElement());
   } else {
     assertNotVisible(proxiedFooterControls.getApplyButtonElement());
     setCurrentDateWithCalendarsTodayButtonAction.perform();
     DateTime inputTime = dateTimeFormatter.parseDateTime(calendar.getInputValue());
     assertEquals(inputTime.getDayOfMonth(), todayMidday.getDayOfMonth());
     assertEquals(inputTime.getMonthOfYear(), todayMidday.getMonthOfYear());
     assertEquals(inputTime.getYear(), todayMidday.getYear());
   }
 }
예제 #20
0
  @Test
  @RegressionTest({
    "https://issues.jboss.org/browse/RF-9837",
    "https://issues.jboss.org/browse/RF-10085"
  })
  public void testDefaultTime() {
    final String t = "06:06";
    calendarAttributes.set(CalendarAttributes.defaultTime, t);
    setCurrentDateWithCalendarsTodayButtonAction.perform();
    String text = calendar.openPopup().getFooterControls().getTimeEditorOpenerElement().getText();
    assertTrue(text.equals(t), "Default time");

    // another check in time editor
    TimeEditor timeEditor = calendar.openPopup().getFooterControls().openTimeEditor();
    DateTime setTime = timeEditor.getTime();
    DateTime reference = todayMidday.withHourOfDay(6).withMinuteOfHour(6);
    assertEquals(setTime.getHourOfDay(), reference.getHourOfDay());
    assertEquals(setTime.getMinuteOfHour(), reference.getMinuteOfHour());
  }
  @Test
  @UseWithField(field = "booleanValue", valuesFrom = FROM_FIELD, value = "booleans")
  @Templates("plain")
  public void testShowFooter() {
    setCurrentDateWithCalendarsTodayButtonAction.perform();
    calendarAttributes.set(CalendarAttributes.showFooter, booleanValue);
    PopupFooterControls fc = popupCalendar.openPopup().getFooterControls();
    if (booleanValue) {
      assertTrue(fc.isVisible(), "Footer elements should be visible, when footer is rendered");
      assertListOfWebElementsVisible(
          Arrays.asList(
              fc.getApplyButtonElement(),
              fc.getCleanButtonElement(),
              fc.getTimeEditorOpenerElement(),
              fc.getTodayButtonElement()));

    } else {
      assertFalse(
          fc.isVisible(), "Footer elements should not be visible, when footer is not rendered");
    }
  }
예제 #22
0
  @Test
  @Use(
      field = "booleanValue",
      booleans = {false, true})
  public void testResetTimeOnDateSelect() {
    calendarAttributes.set(CalendarAttributes.resetTimeOnDateSelect, booleanValue);
    int minutes = 33;

    // set yesterday with some minutes
    MetamerPage.waitRequest(calendar, WaitRequestType.XHR)
        .setDateTime(todayMidday.plusMinutes(minutes).minusDays(1));
    // second time, but without minutes setting, to see if the minutes will reset
    setCurrentDateWithCalendarsTodayButtonAction.perform();

    int minutesAfterReseting =
        dateTimeFormatter.parseDateTime(calendar.getInputValue()).getMinuteOfHour();

    if (booleanValue) {
      assertEquals(minutesAfterReseting, 0);
    } else {
      assertEquals(minutesAfterReseting, minutes);
    }
  }
예제 #23
0
 /** Move mouse to the current element */
 public void moveMouse() {
   Actions builder = new Actions(webdriver);
   Action action = builder.moveToElement(element).build();
   action.perform();
 }
예제 #24
0
 /** Double Click on the element */
 public FluentWebElement doubleClick() {
   Action action = new Actions(FluentThread.get().getDriver()).doubleClick(webElement).build();
   action.perform();
   return this;
 }