@Test(groups = "4.Future")
  @IssueTracking("https://issues.jboss.org/browse/RF-12609")
  public void testShowControls() {
    inplaceInputAttributes.set(InplaceInputAttributes.showControls, Boolean.TRUE);

    assertFalse(inplaceInput.getControls().isVisible(), "Controls should not be visible.");
    assertFalse(
        Graphene.element(inplaceInput.getControls().getCancelButtonElement())
            .isVisible()
            .apply(driver),
        "Cancel button should not be visible.");
    assertFalse(
        Graphene.element(inplaceInput.getControls().getOkButtonElement()).isVisible().apply(driver),
        "Ok button should not be visible.");

    inplaceInput.editBy(OpenBy.CLICK);
    assertTrue(inplaceInput.getControls().isVisible(), "Controls are not visible.");
    assertTrue(
        Graphene.element(inplaceInput.getControls().getCancelButtonElement())
            .isVisible()
            .apply(driver),
        "Cancel button is not visible.");
    assertTrue(
        Graphene.element(inplaceInput.getControls().getOkButtonElement()).isVisible().apply(driver),
        "Ok button is not visible.");
  }
  @Test
  public void testActiveClass() {
    String testedClass = "metamer-ftest-class";
    inplaceInputAttributes.set(InplaceInputAttributes.activeClass, testedClass);

    assertFalse(
        Graphene.attribute(inplaceInput.getRoot(), "class")
            .valueContains(testedClass)
            .apply(driver),
        "Inplace input should not have class metamer-ftest-class.");

    EditingState editingState = inplaceInput.editBy(OpenBy.CLICK);
    assertTrue(
        Graphene.attribute(inplaceInput.getRoot(), "class")
            .valueContains(testedClass)
            .apply(driver),
        "Inplace input should have class metamer-ftest-class.");

    editingState.cancel();

    assertFalse(
        Graphene.attribute(inplaceInput.getRoot(), "class")
            .valueContains(testedClass)
            .apply(driver),
        "Inplace input should not have class metamer-ftest-class.");
  }
Beispiel #3
0
 public void select(int index) {
   final WebElement toSelect = getItemElement(index);
   toSelect.click();
   Graphene.waitAjax()
       .withMessage("The requested item hasn't been selected.")
       .until(Graphene.attribute(toSelect, "class").valueContains("rf-ord-sel"));
 }
 @Test
 public void testShowAndHidePopup() {
   CalendarPopup popup = calendar.getPopup();
   executeJSFromElement(showPopup);
   Graphene.waitGui().withMessage("popup should be visible").until(popup.isVisibleCondition());
   executeJSFromElement(hidePopup);
   Graphene.waitGui()
       .withMessage("popup should not be visible")
       .until(popup.isNotVisibleCondition());
 }
Beispiel #5
0
 /** {@link https://issues.jboss.org/browse/RF-12761} */
 @Test
 @Category(Failing.class)
 public void listener_with_parameter() throws InterruptedException {
   // given
   browser.get(contextPath.toExternalForm());
   WebElement button1 = browser.findElement(By.id("myForm:jsFunction"));
   Graphene.guardAjax(button1).click();
   WebElement button2 = browser.findElement(By.id("myForm2:ajax2"));
   Graphene.guardAjax(button2).click();
 }
Beispiel #6
0
 /**
  * !All requests depends on Metamer`s requestTime! Generates a waiting proxy. The proxy will wait
  * for expected @waitRequestType which will be launched via interactions with @target and then it
  * waits until Metamer's request time changes(@waitRequestType is HTTP or XHR) or not changes
  * (@waitRequestType is NONE).
  *
  * @param <T> type of the given target
  * @param target object to be guarded
  * @param waitRequestType type of expected request which will be launched
  * @param guardTime time for which will be the target guarded, applicable only
  *     for @waitRequestType = NONE
  * @return waiting proxy for target object
  */
 public static <T> T waitRequest(T target, WaitRequestType waitRequestType, long guardTime) {
   switch (waitRequestType) {
     case HTTP:
       return requestTimeChangesWaiting(Graphene.guardHttp(target));
     case XHR:
       return requestTimeChangesWaiting(Graphene.guardAjax(target));
     case NONE:
       return requestTimeNotChangesWaiting(Graphene.guardNoRequest(target), guardTime);
     default:
       throw new UnsupportedOperationException("Not supported request: " + waitRequestType);
   }
 }
 @Test
 public void testShowAndHideTimeEditor() {
   calendar.setDateTime(todayMidday.plusMonths(1));
   TimeEditor timeEditor = calendar.getPopup().getFooterControls().getTimeEditor();
   executeJSFromElement(showTimeEditor);
   Graphene.waitGui()
       .withMessage("time editor should be visible")
       .until(timeEditor.isVisibleCondition());
   executeJSFromElement(hideTimeEditor);
   Graphene.waitGui()
       .withMessage("time editor should not be visible")
       .until(timeEditor.isNotVisibleCondition());
 }
 @Test
 public void testShowAndHideDateEditor() {
   YearAndMonthEditor yearAndMonthEditor =
       calendar.getPopup().getHeaderControls().getYearAndMonthEditor();
   executeJSFromElement(showDateEditor);
   Graphene.waitGui()
       .withMessage("year and month editor should be visible")
       .until(yearAndMonthEditor.isVisibleCondition());
   executeJSFromElement(hideDateEditor);
   Graphene.waitGui()
       .withMessage("year and month editor should not be visible")
       .until(yearAndMonthEditor.isNotVisibleCondition());
 }
  @Test
  public void testDynamicSelects() {

    List<String> fruitsExpected = new ArrayList<String>();
    fruitsExpected.add("");
    fruitsExpected.add("Banana");
    fruitsExpected.add("Cranberry");
    fruitsExpected.add("Blueberry");
    fruitsExpected.add("Orange");

    List<String> vegetablesExpected = new ArrayList<String>();
    vegetablesExpected.add("");
    vegetablesExpected.add("Potatoes");
    vegetablesExpected.add("Broccoli");
    vegetablesExpected.add("Garlic");
    vegetablesExpected.add("Carrot");

    assertTrue(firstSelect.isDisplayed(), "First select should be displayed!");

    //        assertFalse(secondSelect.isDisplayed(), "Second select should be dispayed");

    Graphene.guardAjax(new Select(firstSelect)).selectByVisibleText("Fruits");

    List<String> fruitsActual = new ArrayList<String>();
    List<WebElement> fruitsOptions = new Select(secondSelect).getOptions();
    for (WebElement option : fruitsOptions) {
      fruitsActual.add(option.getText().trim());
    }

    assertTrue(secondSelect.isDisplayed(), "Second select should be dispayed");

    assertEquals(
        fruitsActual,
        fruitsExpected,
        "When selected fruits in first select, in the second "
            + "should be some examples of Fruits");

    Graphene.guardAjax(new Select(firstSelect)).selectByVisibleText("Vegetables");

    List<String> vegetablesActual = new ArrayList<String>();
    List<WebElement> vegetablesOptions = new Select(secondSelect).getOptions();
    for (WebElement option : vegetablesOptions) {
      vegetablesActual.add(option.getText().trim());
    }

    assertEquals(
        vegetablesActual,
        vegetablesExpected,
        "When selected vegetables in first select, in the second "
            + "should be some examples of vegetables");
  }
Beispiel #10
0
  public MetricsAreaFragment getMetricsArea(String title) {
    ////// add property
    By selector =
        By.xpath(
            ".//table[contains(@class, '"
                + PropUtils.get("metrics.container.class")
                + "')][.//h3[text()='"
                + title
                + "']]");
    WebElement element = null;
    try {
      element = getContentRoot().findElement(selector);
    } catch (NoSuchElementException exc) {
      return null;
    }
    MetricsAreaFragment area = Graphene.createPageFragment(MetricsAreaFragment.class, element);

    Map<String, String> metricGrid =
        element
            .findElement(By.className(PropUtils.get("metrics.grid.class")))
            .findElements(By.tagName("tr"))
            .stream()
            .collect(
                Collectors.toMap(
                    e ->
                        e.findElement(By.className(PropUtils.get("metrics.grid.nominal.class")))
                            .getText(),
                    e ->
                        e.findElement(By.className(PropUtils.get("metrics.grid.numerical.class")))
                            .getText()));

    area.setMetricGrid(metricGrid);

    return area;
  }
  protected void selectOptionByLabel(WebElement menuElement, String text, boolean guardAjax) {
    String menuId = getEscapedElementId(menuElement);
    WebElement trigger = menuElement.findElement(By.cssSelector("div.ui-selectonemenu-trigger"));
    trigger.click();

    String menuItemsContainerId = menuId + "_panel";
    List<WebElement> options =
        driver.findElements(
            By.cssSelector("#" + menuItemsContainerId + " tr.ui-selectonemenu-item"));
    if (options.isEmpty()) {
      options =
          driver.findElements(
              By.cssSelector("#" + menuItemsContainerId + " li.ui-selectonemenu-item"));
    }
    String selectedOptionText = getSelectedOptionText(menuElement);
    for (WebElement option : options) {
      if (option.getAttribute("data-label").equals(text)) {
        if (guardAjax && !selectedOptionText.equals(text)) {
          Graphene.guardAjax(option).click();
        } else {
          option.click();
        }
        break;
      }
    }
  }
 protected void setCheckboxState(WebElement checkboxElement, boolean checked) {
   if ((checked == true && !isCheckboxChecked(checkboxElement))
       || (checked == false && isCheckboxChecked(checkboxElement))) {
     WebElement trigger = checkboxElement.findElement(By.cssSelector("div.ui-chkbox-box"));
     Graphene.guardAjax(trigger).click();
   }
 }
Beispiel #13
0
  private void setTextValue(ResourceTableRowFragment row, int index, String text) {
    WebElement cell = row.getCell(index);
    cell.click();

    By selector = ByJQuery.selector("input");

    Graphene.waitModel().until().element(cell, selector).is().present();

    WebElement input = cell.findElement(selector);

    input.clear();

    input.sendKeys(text);

    Graphene.waitGui().until().element(input).attribute("value").contains(text);
  }
  public void testMoveWithSlider() {
    moveWithSliderActionWithWaitRequest(0).perform();
    Graphene.waitGui().until().element(output).text().equalTo("-10");
    assertEquals(slider.advanced().getInput().getStringValue(), "-10", "Input was not updated.");
    assertEquals(output.getText(), "-10", "Output was not updated.");

    moveWithSliderActionWithWaitRequest(35).perform();
    Graphene.waitGui().until().element(output).text().equalTo("-7");
    assertEquals(slider.advanced().getInput().getStringValue(), "-7", "Input was not updated.");
    assertEquals(output.getText(), "-7", "Output was not updated.");

    moveWithSliderActionWithWaitRequest(slider.advanced().getWidth()).perform();
    Graphene.waitGui().until().element(output).text().equalTo("10");
    assertEquals(slider.advanced().getInput().getStringValue(), "10", "Input was not updated.");
    assertEquals(output.getText(), "10", "Output was not updated.");
  }
  protected void checkContextMenuRenderedAtCorrectPosition(
      WebElement target,
      WebElement contextMenuPopup,
      InvocationType type,
      ExpectedCondition<Boolean> conditionTargetIsFocused) {

    if (conditionTargetIsFocused != null) {
      target.click();
      Graphene.waitGui(webDriver).withTimeout(2, TimeUnit.SECONDS).until(conditionTargetIsFocused);
    }
    waitGui();

    // clicks in the middle of the target
    switch (type) {
      case LEFT_CLICK:
        actions.click(target);
        break;
      case RIGHT_CLICK:
        actions.contextClick(target);
        break;
      default:
        throw new IllegalArgumentException("Wrong type of context menu invocation!");
    }
    actions.build().perform();

    Graphene.waitGui()
        .withTimeout(2, TimeUnit.SECONDS)
        .until()
        .element(contextMenuPopup)
        .is()
        .visible();

    Point locationOfTarget = target.getLocation();
    Point locationOfCtxMenu = contextMenuPopup.getLocation();

    double witdth = getTargetWidth(target);
    double height = getTargetHeight(target);

    double halfOfDiagonal = Math.sqrt((height * height) + (witdth * witdth)) / 2.0;
    double distance = getDistance(locationOfTarget, locationOfCtxMenu);

    double result = halfOfDiagonal - distance;

    assertTrue(
        result >= 0 && result < TOLERANCE,
        "The context menu was not rendered on the correct position! The difference is: " + result);
  }
  @Test
  public void testDisabled() {
    inplaceInputAttributes.set(InplaceInputAttributes.disabled, Boolean.TRUE);

    assertTrue(inplaceInput.isVisible(), "Inplace input is not on the page.");
    assertEquals(inplaceInput.getLabelValue(), "RichFaces 4", "Default label");
    assertFalse(
        Graphene.element(inplaceInput.getControls().getCancelButtonElement())
            .isVisible()
            .apply(driver),
        "OK button should not be present on the page.");
    assertFalse(
        Graphene.element(inplaceInput.getControls().getCancelButtonElement())
            .isVisible()
            .apply(driver),
        "Cancel button should not be present on the page.");
  }
  public ResourceTableFragment getResourceTable() {
    By selector = ByJQuery.selector(".default-cell-table[role='grid']:visible");
    WebElement tableRoot = getContentRoot().findElement(selector);
    ResourceTableFragment table =
        Graphene.createPageFragment(ResourceTableFragment.class, tableRoot);

    return table;
  }
 @Override
 public List<RECORD> getAllVisibleRecords() {
   List<RECORD> result = new ArrayList<RECORD>();
   for (WebElement recordRoot : recordsElements) {
     result.add(Graphene.createPageFragment(recordClass, recordRoot));
   }
   return result;
 }
Beispiel #19
0
 protected void afterAction(GrapheneContext context) {
   Graphene.waitModel(context.getWebDriver())
       .until()
       .element(REQUEST_TIME)
       .text()
       .not()
       .equalTo(time1);
 }
  /**
   * Returns the ConfigArea portion of page as given implementation. Not reliable - you might need
   * to override this method.
   *
   * @param clazz
   * @param <T>
   * @return
   */
  public <T extends ConfigAreaFragment> T getConfig(Class<T> clazz) {
    By selector =
        getConfigSelector(); // TODO: replace with proper selector once there is a usable class
    WebElement configRoot = getContentRoot().findElement(selector);
    T config = Graphene.createPageFragment(clazz, configRoot);

    return config;
  }
 @Override
 public void setDateTime(DateTime dt) {
   if (Graphene.element(getFooterControls().getApplyButtonElement()).isVisible().apply(driver)) {
     super.setDateTime(dt);
     getFooterControls().getApplyButtonElement().click();
   } else {
     getHeaderControls().openYearAndMonthEditor().selectDate(dt).confirmDate();
     getDayPicker().selectDayInMonth(dt);
     if (Graphene.element(getProxiedFooterControls().getTimeEditorOpenerElement())
         .isVisible()
         .apply(driver)) {
       getProxiedFooterControls()
           .openTimeEditor()
           .setTime(dt, TimeEditor.SetValueBy.TYPING)
           .confirmTime();
     }
   }
 }
 @Test
 public void testInit() {
   assertTrue(inplaceInput.isVisible(), "Inplace input is not on the page.");
   assertEquals(inplaceInput.getLabelValue(), "RichFaces 4", "Default label");
   assertEquals(inplaceInput.getEditValue(), "RichFaces 4", "Default value of input");
   assertTrue(
       Graphene.element(inplaceInput.getControls().getOkButtonElement())
           .not()
           .isVisible()
           .apply(driver),
       "OK button should not be present on the page.");
   assertTrue(
       Graphene.element(inplaceInput.getControls().getCancelButtonElement())
           .not()
           .isVisible()
           .apply(driver),
       "Cancel button should not be present on the page.");
 }
 @Test(groups = {"RF-11871"})
 public void testStop() throws InterruptedException {
   getPage().getButton().click();
   String before = getPage().getDate().getText();
   Thread.sleep(1500);
   Graphene.waitAjax()
       .withMessage("After clicking on the stop button, there should be not updates.")
       .until(new WebElementConditionFactory(getPage().getDate()).textEquals(before));
 }
  @Test
  @Templates(value = {"plain"})
  public void testSwitchToItem() {
    List<WebElement> buttons =
        Lists.newArrayList(switchTo1Button, switchTo2Button, switchTo3Button, switchTo5Button);
    List<String> headers = Lists.newArrayList("Item 1", "Item 2", "Item 3", "Item 5");
    for (int i = 0; i < buttons.size(); i++) {
      Graphene.guardAjax(buttons.get(i)).click();
      assertEquals(accordion.advanced().getActiveItem().advanced().getHeader(), headers.get(i));
    }

    // switch to disabled item
    Graphene.guardNoRequest(switchTo4Button).click();
    assertEquals(
        accordion.advanced().getActiveItem().advanced().getHeader(),
        "Item 5",
        "Active item should not change.");
  }
 public void addNewContent(
     String firstName, String lastName, String address, String city, String telephone) {
   this.firstName.sendKeys(firstName);
   this.lastName.sendKeys(lastName);
   this.address.sendKeys(address);
   this.city.sendKeys(city);
   this.telephone.sendKeys(telephone);
   Graphene.guardHttp(this.save).click();
 }
  @Test
  public void testEnableManualInput() {
    assertEquals(calendar.getInput().getAttribute("readonly"), "true");

    calendarAttributes.set(CalendarAttributes.enableManualInput, Boolean.TRUE);
    assertTrue(
        Graphene.attribute(calendar.getInput(), "readonly").not().isPresent().apply(driver),
        "Readonly attribute of input should not be defined.");
  }
Beispiel #27
0
 @Test(groups = "Future")
 public void testClickOnTheNextMonthAndJSErrorIsThrown() {
   page.getLog().changeLevel(LogEntryLevel.ERROR);
   page.getShowCalendarButton().click();
   Graphene.waitAjax().until().element(page.getNextMonthScroller()).is().visible();
   guardAjax(page.getNextMonthScroller()).click();
   assertTrue(
       page.getLog().getLogEntries().isEmpty(), "There should be no errors on the log screen!");
 }
Beispiel #28
0
  private void waitForNewLine() {
    String emptyNameLabel = PropUtils.get("editor.shared.property.empty.key.label");

    String emptyValueLabel = PropUtils.get("editor.shared.property.empty.value.label");
    By selector =
        ByJQuery.selector(
            "tr:contains('" + emptyNameLabel + "')" + ":contains('" + emptyValueLabel + "')");

    Graphene.waitGui().until().element(getTable().getRoot(), selector);
  }
  @Test
  public void testChangedClass() {
    String testedClass = "metamer-ftest-class";
    inplaceInputAttributes.set(InplaceInputAttributes.changedClass, testedClass);

    assertFalse(
        Graphene.attribute(inplaceInput.getRoot(), "class")
            .valueContains(testedClass)
            .apply(driver),
        "Inplace input should not have class metamer-ftest-class.");

    MetamerPage.waitRequest(inplaceInput.editBy(OpenBy.CLICK).type("s"), WaitRequestType.XHR)
        .confirm();
    assertTrue(
        Graphene.attribute(inplaceInput.getRoot(), "class")
            .valueContains(testedClass)
            .apply(driver),
        "Inplace input should have class metamer-ftest-class.");
  }
  @Test
  public void testDisabled() {
    calendarAttributes.set(CalendarAttributes.disabled, Boolean.TRUE);
    assertEquals(calendar.getInput().getAttribute("disabled"), "true");

    // Popup should not be displayed
    int catched = 0;
    try {
      Graphene.guardNoRequest(calendar).openPopup(OpenedBy.INPUT_CLICKING);
    } catch (TimeoutException ex) {
      catched++;
    }
    try {
      Graphene.guardNoRequest(calendar).openPopup(OpenedBy.OPEN_BUTTON_CLICKING);
    } catch (TimeoutException ex) {
      catched++;
    }
    assertTrue(catched == 2);
  }