コード例 #1
0
ファイル: TestRichEditor.java プロジェクト: kenfinnigan/qa
 /**
  * Simplified method to verify skin influence editor's class attribute. Choosen skin should be
  * present as cke_skin_{@skinName} class in editor's container @@class attribute
  *
  * @param skinName
  */
 private void verifySkin(String skinName) {
   editorAttributes.set(skin, skinName);
   String editorClass = selenium.getAttribute(editor.getAttribute(new Attribute("class")));
   assertTrue(
       editorClass.contains("cke_skin_" + skinName),
       "Seems that skin '" + skinName + "' didn't influence editor's @class attribute!");
 }
コード例 #2
0
ファイル: TestRichEditor.java プロジェクト: kenfinnigan/qa
  @Test
  @RegressionTest("https://issues.jboss.org/browse/RFPL-1658")
  public void testReadonly() {

    editorAttributes.set(readonly, Boolean.TRUE);

    String readOnlyAttrVal =
        selenium.getAttribute(editorTextArea.getAttribute(new Attribute("readonly")));
    assertEquals(readOnlyAttrVal, "readonly");

    selenium.selectFrame(frameLocator);
    String contentEditableVal =
        selenium.getAttribute(editorArea.getAttribute(new Attribute("contenteditable")));
    assertEquals(contentEditableVal, "false");

    selenium.selectFrame(FrameRelativeLocator.TOP);
  }
コード例 #3
0
ファイル: TestRichEditor.java プロジェクト: kenfinnigan/qa
  @Test
  @RegressionTest("https://issues.jboss.org/browse/RF-11394")
  public void testLang() {
    String langVal = "xyz";
    editorAttributes.set(lang, langVal);

    assertTrue(langVal.equals(selenium.getAttribute(editorTextArea.getAttribute(langAttribute))));
  }
コード例 #4
0
ファイル: TestArrangeableModel.java プロジェクト: lfryc/qa
  private boolean doesColumnContainsOnlyRowsWithData(String column, String data) {

    JQueryLocator table = jq(this.table.getRawLocator() + " > tr");

    for (Iterator<JQueryLocator> i = table.iterator(); i.hasNext(); ) {

      JQueryLocator td = jq(i.next().getRawLocator() + " > " + column);

      String tdText = selenium.getText(td);

      if (!tdText.toLowerCase().contains(data)) {

        return false;
      }
    }

    return true;
  }
コード例 #5
0
ファイル: TestSimple.java プロジェクト: jjamrich/qa
  private void checkToogleTab(JQueryLocator button, String expectedContent) {

    guardXhr(selenium).click(button);

    String actualContent = selenium.getText(bodyOfPanel);

    assertTrue(
        actualContent.contains(expectedContent),
        "The content of " + button.getRawLocator() + " is diferent!");
  }
コード例 #6
0
ファイル: TestRichEditor.java プロジェクト: kenfinnigan/qa
  @Test
  public void testStyleClass() {

    final String styleClassVal = "metamer-ftest-class";
    editorAttributes.set(styleClass, styleClassVal);

    JQueryLocator elementWhichHasntThatClass =
        jq(editor.getRawLocator() + ":not(.{0})").format(styleClassVal);
    waitModel.until(elementPresent.locator(editor));
    assertTrue(selenium.isElementPresent(editor));
    assertFalse(selenium.isElementPresent(elementWhichHasntThatClass));
  }
コード例 #7
0
ファイル: TestRichEditor.java プロジェクト: kenfinnigan/qa
  @Test
  public void testHeight() {

    String height = "250px";
    editorAttributes.set(EditorAttributes.height, height);

    // height style is set for area used as editor canvas (not for whole editor component)
    // String style = selenium.getAttribute(
    //    editor.getDescendant(jq("table.cke_editor tr:eq(1) td")).getAttribute(styleAttribute));
    String style =
        selenium.getStyle(
            editor.getDescendant(jq("table.cke_editor tr:eq(1) td")), CssProperty.HEIGHT);
    assertTrue(style != null && style.contains(height));
  }
コード例 #8
0
ファイル: TestArrangeableModel.java プロジェクト: lfryc/qa
  private void ascendingDescendingSortingOnColumn(int column, String firstCharOfRowWhenDescending) {

    // ascending
    guardXhr(selenium).click(unsortedLink.format(column));

    JQueryLocator td = firstRowSomeColumn.format(column);
    String checkedValue = selenium.getText(td);

    assertEquals(
        String.valueOf(checkedValue.charAt(0)),
        "A",
        "Rows should be sorted in an ascending order, by column " + td.getRawLocator());

    // descending
    guardXhr(selenium).click(ascendingLink);

    checkedValue = selenium.getText(td);

    assertEquals(
        String.valueOf(checkedValue.charAt(0)),
        firstCharOfRowWhenDescending,
        "Rows should be sorted in an descending order, by column " + td.getRawLocator());
  }
コード例 #9
0
  @Test
  public void testSelectWithMouse() {
    guardNoRequest(selenium).mouseDown(button);
    selenium.mouseUp(button);
    assertTrue(selenium.isVisible(popup), "Popup should be displayed.");

    for (int i = 0; i < 50; i++) {
      assertTrue(
          selenium.isVisible(options.format(i)), "Select option " + i + " should be displayed.");
    }

    String[] selectOptions = {"Alabama", "Hawaii", "Massachusetts", "New Mexico", "South Dakota"};
    for (int i = 0; i < 50; i += 10) {
      assertEquals(
          selenium.getText(options.format(i)), selectOptions[i / 10], "Select option nr. " + i);
    }

    guardNoRequest(selenium).click(options.format(10));
    guardXhr(selenium).fireEvent(input, Event.BLUR);
    assertTrue(selenium.belongsClass(options.format(10), "rf-sel-sel"));

    waitGui.failWith("Bean was not updated").until(textEquals.locator(output).text("Hawaii"));
    phaseInfo.assertListener(PhaseId.PROCESS_VALIDATIONS, "value changed: null -> Hawaii");
  }
コード例 #10
0
ファイル: TestRichEditor.java プロジェクト: kenfinnigan/qa
  @Test
  public void testStyle() {

    final AttributeLocator<?> styleAttr = editor.getAttribute(Attribute.STYLE);
    final String style = "background-color: yellow; font-size: 1.5em;";

    editorAttributes.set(EditorAttributes.style, style);

    waitModel
        .failWith("Attribute style should contain \"" + style + "\"")
        .until(
            new SeleniumCondition() {
              @Override
              public boolean isTrue() {
                return selenium.getAttribute(styleAttr).contains(style);
              }
            });
  }
コード例 #11
0
ファイル: TestRichEditor.java プロジェクト: kenfinnigan/qa
  @Test
  public void testTitle() {

    String titleVal = "RichFaces 4";
    AttributeLocator<?> attribute = editor.getAttribute(new Attribute("title"));

    // title = null
    assertFalse(
        titleVal.equals(selenium.getAttribute(attribute)),
        "Attribute title should not be present.");

    // set title
    editorAttributes.set(title, titleVal);

    // wait until attribute present
    assertTrue(selenium.isAttributePresent(attribute), "Attribute title should be present.");
    // assert correct attribute value: title
    waitModel.until(attributeEquals.locator(attribute).text(titleVal));
  }
コード例 #12
0
ファイル: TestSideMenu.java プロジェクト: lfryc/qa
  private void hoverOverOptionAndCheckTheSubmenu(int numberOfSubmenu) {

    JQueryLocator optionLabel =
        jq(optionList.getRawLocator() + ":eq(" + numberOfSubmenu + ") " + firstLvlLabels);
    JQueryLocator optionSecondLvlStyle =
        jq(styleOfSecondLvlOptions + ":eq(" + numberOfSubmenu + ") > div");

    boolean isDisplayedBeforeHovering = selenium.isVisible(optionSecondLvlStyle);
    assertFalse(
        isDisplayedBeforeHovering,
        "The second lvl options should not be displayed since the "
            + "was no hovering over "
            + optionLabel
            + " yet");

    guardNoRequest(selenium).fireEvent(optionLabel, Event.MOUSEOVER);

    boolean isDisplayedAfterHovering = selenium.isVisible(optionSecondLvlStyle);
    assertTrue(
        isDisplayedAfterHovering,
        "The second lvl options should be displayed "
            + "since there was hover over element "
            + optionLabel);
  }
コード例 #13
0
  private void testOneRunOfProgressBar(JQueryLocator button, int interval) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss.SSS");
    long delta = (long) (interval * 0.5);
    Set<String> timesSet = new TreeSet<String>();
    List<String> labelsList = new ArrayList<String>();
    List<String> progressList = new ArrayList<String>();

    guardXhr(selenium).click(button);

    for (int i = 0; i < 40; i++) {
      waitFor(delta);
      timesSet.add(selenium.getText(time));
      labelsList.add(selenium.getText(label).replace(" %", ""));
      String width =
          selenium
              .getAttribute(progress.getAttribute(Attribute.STYLE))
              .replace("%", "")
              .replace("width:", "");
      progressList.add(width.replace(";", "").trim());
    }

    Date[] timesArray = new Date[timesSet.size()];
    List<String> timesList = new ArrayList<String>(timesSet);

    for (int i = 1; i < timesList.size(); i++) {
      timesArray[i] = sdf.parse(timesList.get(i));
    }

    long average = countAverage(timesArray);
    assertTrue(
        Math.abs(average - interval) < delta,
        "Average interval " + average + " is too far from set value (" + interval + ")");
    assertFalse(
        average < interval,
        "Average interval " + average + " cannot be smaller than set value (" + interval + ")");

    int first, second;
    for (int i = 0; i < labelsList.size() - 1; i++) {
      first = Integer.parseInt(labelsList.get(i));
      second = Integer.parseInt(labelsList.get(i + 1));
      assertTrue(
          first <= second,
          "Number of percent in label should be increasing: " + first + "!<= " + second);
    }

    for (int i = 0; i < progressList.size() - 1; i++) {
      first = Integer.parseInt(progressList.get(i));
      second = Integer.parseInt(progressList.get(i + 1));
      assertTrue(
          first <= second,
          "Progress of progress bar should be increasing: " + first + "!<= " + second);
    }

    waitGui
        .timeout(40000)
        .failWith("Progress bar should disappear after it finishes.")
        .until(elementPresent.locator(restartButton));
    assertTrue(
        selenium.isElementPresent(completeOutput),
        "Complete output should be present on the page.");

    assertTrue(selenium.isVisible(progressBar), "Progress bar is not present on the page.");
    assertFalse(
        selenium.isElementPresent(initialOutput),
        "Initial output should not be present on the page.");
    assertTrue(
        selenium.isVisible(completeOutput), "Complete output should be present on the page.");
    assertFalse(
        selenium.isElementPresent(startButton), "Start button should not be present on the page.");
    assertTrue(selenium.isVisible(restartButton), "Restart button should be present on the page.");

    assertFalse(selenium.isVisible(remain), "Progress bar should not show progress.");
  }
コード例 #14
0
ファイル: TestArrangeableModel.java プロジェクト: lfryc/qa
/**
 * @author <a href="mailto:[email protected]">Juraj Huska</a>
 * @version $Revision$
 */
public class TestArrangeableModel extends AbstractShowcaseTest {

  /* *******************************************************************************************
   * Locators
   * ******************************************************************
   * *************************
   */

  protected JQueryLocator firstNameFilterInput = jq("input[type=text]:eq(0)");
  protected JQueryLocator secondNameFilterInput = jq("input[type=text]:eq(1)");
  protected JQueryLocator emailFilterInput = jq("input[type=text]:eq(2)");
  protected JQueryLocator table = jq("tbody.rf-dt-b");
  // these are links for filtering rows in a ascending, descending way
  // 0 is for first name column, 1 surname, 2 email
  protected JQueryLocator unsortedLink = jq("a[onClick*='RichFaces']:eq({0})");
  protected JQueryLocator ascendingLink = jq("a:contains(ascending)");
  protected JQueryLocator descendingLink = jq("a:contains(descending)");
  protected JQueryLocator firstRowSomeColumn =
      jq(table.getRawLocator() + " > tr:eq(0) > td:eq({0})");

  /* *******************************************************************************************
   * Tests
   * *********************************************************************
   * **********************
   */

  @Test
  public void testTableIsNotEmpty() {

    testWhetherTableContainsNonEmptyStrings(table);
  }

  @Test
  public void testFirstNameFilter() {

    filterAnColumn(firstNameFilterInput, "as", "td:eq(0)");
    eraseInput(firstNameFilterInput);
    guardXhr(selenium).fireEvent(firstNameFilterInput, Event.KEYUP);
  }

  @Test
  public void testSurnameFilter() {

    filterAnColumn(secondNameFilterInput, "al", "td:eq(1)");
    eraseInput(secondNameFilterInput);
    guardXhr(selenium).fireEvent(secondNameFilterInput, Event.KEYUP);
  }

  @Test
  public void testEmailFilter() {

    filterAnColumn(emailFilterInput, "ac", "td:eq(2)");
    eraseInput(emailFilterInput);
    guardXhr(selenium).fireEvent(emailFilterInput, Event.KEYUP);
  }

  @Test
  public void testFirstNameSorting() {

    ascendingDescendingSortingOnColumn(0, "Z");
  }

  @Test
  public void testSurnameSorting() {

    ascendingDescendingSortingOnColumn(1, "Z");
  }

  @Test
  public void testEmailSorting() {

    ascendingDescendingSortingOnColumn(2, "v");
  }

  /* **********************************************************************************************
   * Help methods
   * **************************************************************
   * ********************************
   */

  private boolean doesColumnContainsOnlyRowsWithData(String column, String data) {

    JQueryLocator table = jq(this.table.getRawLocator() + " > tr");

    for (Iterator<JQueryLocator> i = table.iterator(); i.hasNext(); ) {

      JQueryLocator td = jq(i.next().getRawLocator() + " > " + column);

      String tdText = selenium.getText(td);

      if (!tdText.toLowerCase().contains(data)) {

        return false;
      }
    }

    return true;
  }

  private void filterAnColumn(JQueryLocator filterInput, String filterValue, String column) {

    selenium.type(filterInput, filterValue);
    guardXhr(selenium).fireEvent(filterInput, Event.KEYUP);

    boolean result = doesColumnContainsOnlyRowsWithData(column, filterValue);

    assertTrue(
        result,
        "The table should contains only rows, which column "
            + column
            + " contains only data "
            + filterValue);
  }

  private void ascendingDescendingSortingOnColumn(int column, String firstCharOfRowWhenDescending) {

    // ascending
    guardXhr(selenium).click(unsortedLink.format(column));

    JQueryLocator td = firstRowSomeColumn.format(column);
    String checkedValue = selenium.getText(td);

    assertEquals(
        String.valueOf(checkedValue.charAt(0)),
        "A",
        "Rows should be sorted in an ascending order, by column " + td.getRawLocator());

    // descending
    guardXhr(selenium).click(ascendingLink);

    checkedValue = selenium.getText(td);

    assertEquals(
        String.valueOf(checkedValue.charAt(0)),
        firstCharOfRowWhenDescending,
        "Rows should be sorted in an descending order, by column " + td.getRawLocator());
  }
}