public void checkShowSummary() {
   messageAttributes.set(MessageAttributes.showDetail, Boolean.TRUE);
   messageAttributes.set(MessageAttributes.showSummary, Boolean.TRUE);
   generateValidationMessagesWithWait();
   assertVisible(
       getMessageComponentForFirstInput().advanced().getSummaryElement(),
       "Message should be visible.");
   assertVisible(
       getMessageComponentForSecondInput().advanced().getSummaryElement(),
       "Message should be visible.");
   assertVisible(
       getMessageComponentForSelectableInput().advanced().getSummaryElement(),
       "Message should be visible.");
   messageAttributes.set(MessageAttributes.showSummary, Boolean.FALSE);
   generateValidationMessagesWithWait();
   assertNotVisible(
       getMessageComponentForFirstInput().advanced().getSummaryElement(),
       "Message should not be visible.");
   assertNotVisible(
       getMessageComponentForSecondInput().advanced().getSummaryElement(),
       "Message should not be visible.");
   assertNotVisible(
       getMessageComponentForSelectableInput().advanced().getSummaryElement(),
       "Message should not be visible.");
 }
  public void testMode() {
    updateDropDownMenuInvoker();
    // ajax
    dropDownMenuAttributes.set(DropDownMenuAttributes.mode, "ajax");
    getCurrentMenu().advanced().show(page.getTarget1());
    guardAjax(getCurrentMenu().advanced().getItemsElements().get(0)).click();
    assertEquals(page.getOutput().getText(), "New", "Menu action was not performed.");

    // server
    dropDownMenuAttributes.set(DropDownMenuAttributes.mode, "server");
    getCurrentMenu().advanced().show(page.getTarget1());
    guardHttp(getCurrentMenu().advanced().getItemsElements().get(8)).click();
    assertEquals(page.getOutput().getText(), "Close", "Menu action was not performed.");

    // client
    dropDownMenuAttributes.set(DropDownMenuAttributes.mode, "client");
    getCurrentMenu().advanced().show(page.getTarget1());
    guardNoRequest(getCurrentMenu().advanced().getItemsElements().get(0)).click();

    // null
    dropDownMenuAttributes.set(DropDownMenuAttributes.mode, "server");
    getCurrentMenu().advanced().show(page.getTarget1());
    guardHttp(getCurrentMenu().advanced().getItemsElements().get(8)).click();
    assertEquals(page.getOutput().getText(), "Close", "Menu action was not performed.");
  }
 protected void increase(int count) {
   Double maxValue =
       Double.parseDouble(inputNumberSpinnerAttributes.get(InputNumberSpinnerAttributes.maxValue));
   Boolean cycled =
       Boolean.parseBoolean(inputNumberSpinnerAttributes.get(InputNumberSpinnerAttributes.cycled));
   Double actValue;
   WaitRequestType type;
   for (int i = 0; i < count; i++) {
     actValue = Double.parseDouble(spinner.advanced().getInput().getStringValue());
     type = (actValue < maxValue || cycled ? WaitRequestType.XHR : WaitRequestType.NONE);
     MetamerPage.waitRequest(spinner, type).increase();
   }
 }
  public void testShowEvent() {
    dropDownMenuAttributes.set(DropDownMenuAttributes.showEvent, "contextmenu");
    getCurrentMenu().advanced().setupShowEvent(Event.CONTEXTCLICK);
    getCurrentMenu().advanced().show(page.getTarget1());

    dropDownMenuAttributes.set(DropDownMenuAttributes.showEvent, "mouseover");
    getCurrentMenu().advanced().setupShowEvent(Event.MOUSEOVER);
    getCurrentMenu().advanced().show(page.getTarget1());

    dropDownMenuAttributes.set(DropDownMenuAttributes.showEvent, "click");
    getCurrentMenu().advanced().setupShowEvent(Event.CLICK);
    getCurrentMenu().advanced().show(page.getTarget1());
  }
 public void testStyleClass() {
   updateDropDownMenuInvoker();
   String styleClassVal = "test-style-class";
   dropDownMenuAttributes.set(DropDownMenuAttributes.styleClass, styleClassVal);
   String styleClass = getCurrentMenu().advanced().getTopLevelElement().getAttribute("class");
   assertTrue(styleClass.contains(styleClassVal));
 }
  @Test
  public void testSwitchTypeClient() {
    accordionItemAttributes.set(AccordionItemAttributes.switchType, "client");

    guardNoRequest(page.getItemHeaders().get(0)).click();
    waitGui(driver).until().element(page.getItemContents().get(0)).is().visible();
  }
  @Test
  @Templates("plain")
  public void testSwitchTypeAjax() {
    accordionItemAttributes.set(AccordionItemAttributes.switchType, "ajax");

    testSwitchTypeNull();
  }
  @Test
  public void testSwitchTypeServer() {
    accordionItemAttributes.set(AccordionItemAttributes.switchType, "server");

    guardHttp(page.getItemHeaders().get(0)).click();
    waitModel(driver).until().element(page.getItemContents().get(0)).is().visible();
  }
  public void checkFor() {
    // firstly, remove value from attribute @for and generate message
    messageAttributes.set(MessageAttributes.FOR, "");
    generateValidationMessages();
    submitWithA4jBtn();
    assertFalse(
        getMessageComponentForSelectableInput().advanced().isVisible(),
        "Message should not be visible.");

    // now set for attribute back to "simpleInput2"
    messageAttributes.set(MessageAttributes.FOR, "simpleInput2");
    generateValidationMessagesWithWait();
    assertTrue(
        getMessageComponentForSelectableInput().advanced().isVisible(),
        "Message should be visible.");
  }
  public void checkAjaxRendered() {
    generateValidationMessagesWithWait();
    assertTrue(
        getMessageComponentForFirstInput().advanced().isVisible(), "Message should be visible.");
    assertTrue(
        getMessageComponentForSecondInput().advanced().isVisible(), "Message should be visible.");
    assertTrue(
        getMessageComponentForSelectableInput().advanced().isVisible(),
        "Message should be visible.");

    messageAttributes.set(MessageAttributes.ajaxRendered, Boolean.FALSE);
    generateValidationMessagesWithWait();
    assertFalse(
        getMessageComponentForFirstInput().advanced().isVisible(),
        "Message should not be visible.");
    assertFalse(
        getMessageComponentForSecondInput().advanced().isVisible(),
        "Message should not be visible.");
    assertFalse(
        getMessageComponentForSelectableInput().advanced().isVisible(),
        "Message should not be visible.");
    // submit with h:commandbutton
    MetamerPage.waitRequest(getPage().gethCommandButton(), WaitRequestType.HTTP).click();
    assertTrue(
        getMessageComponentForFirstInput().advanced().isVisible(), "Message should be visible.");
    assertTrue(
        getMessageComponentForSecondInput().advanced().isVisible(), "Message should be visible.");
    assertTrue(
        getMessageComponentForSelectableInput().advanced().isVisible(),
        "Message should be visible.");
  }
 @Test
 @RegressionTest("https://issues.jboss.org/browse/RF-10488")
 public void testName() {
   accordionItemAttributes.set(AccordionItemAttributes.name, "new name");
   guardAjax(driver.findElement(ByJQuery.selector("input[type=submit][name$=switchButtonCustom]")))
       .click();
   waitAjax(driver).until().element(page.getItemContents().get(0)).is().visible();
 }
  @Test
  @Templates("plain")
  @RegressionTest("https://issues.jboss.org/browse/RF-10297")
  public void testHeaderDisabledClass() {
    accordionItemAttributes.set(AccordionItemAttributes.disabled, true);

    testStyleClass(page.getDisabledHeaders().get(0), headerDisabledClass);
  }
  public void checkNoShowDetailNoShowSummary() {
    messageAttributes.set(MessageAttributes.showSummary, Boolean.FALSE);
    messageAttributes.set(MessageAttributes.showDetail, Boolean.FALSE);

    generateValidationMessages();
    submitWithA4jBtn();

    assertFalse(
        getMessageComponentForFirstInput().advanced().isVisible(),
        "Message should not be visible.");
    assertFalse(
        getMessageComponentForSecondInput().advanced().isVisible(),
        "Message should not be visible.");
    assertFalse(
        getMessageComponentForSelectableInput().advanced().isVisible(),
        "Message should not be visible.");
  }
 @Test
 @Templates("plain")
 public void testLabel() {
   String testedLabel = "new label";
   menuGroupAttributes.set(MenuGroupAttributes.label, testedLabel);
   openMenuAndSubMenu();
   assertEquals(label.getText(), testedLabel, "New label of the menu group.");
 }
  @Test(groups = "smoke")
  @RegressionTest("https://issues.jboss.org/browse/RF-9989")
  @Templates(value = "plain")
  public void testIcon() {
    menuGroupAttributes.set(MenuGroupAttributes.icon, "null");
    assertNotPresent(icon, "Icon should not be present.");
    assertPresent(emptyIcon, "Empty icon should be present.");

    menuGroupAttributes.set(MenuGroupAttributes.icon, "star");
    assertTrue(
        icon.getAttribute("src").contains("star.png"),
        "Icon's src attribute should contain \"star.png\".");

    menuGroupAttributes.set(MenuGroupAttributes.icon, "nonexisting");
    assertTrue(
        icon.getAttribute("src").contains("nonexisting"),
        "Icon's src attribute should contain \"nonexisting\".");
  }
  @Test
  public void testDisabled() {
    menuGroupAttributes.set(MenuGroupAttributes.disabled, Boolean.TRUE);

    assertTrue(
        group.getAttribute("class").contains("rf-ddm-itm-dis"),
        "Menu group should have class \"rf-ddm-itm-dis\".");
    assertPresent(emptyIcon, "Empty icon should be present.");
    assertNotPresent(icon, "Icon should not be present.");
  }
  public void testDir() {
    updateDropDownMenuInvoker();
    String expected = "rtl";
    dropDownMenuAttributes.set(DropDownMenuAttributes.dir, expected);

    getCurrentMenu().advanced().show(page.getTarget1());
    String directionCSS =
        getCurrentMenu().advanced().getItemsElements().get(0).getCssValue("direction");
    assertEquals(directionCSS, expected, "The direction attribute was not applied correctly!");
  }
  public void testLang() {
    updateDropDownMenuInvoker();
    String langVal = "cs";
    dropDownMenuAttributes.set(DropDownMenuAttributes.lang, langVal);
    getCurrentMenu().advanced().show(page.getTarget1());

    assertEquals(
        getCurrentMenu().advanced().getLangAttribute(),
        langVal,
        "The lang attribute was not set correctly!");
  }
  @Test
  @Templates(value = {"plain"})
  public void testPreviousItemWithCycledSwitching() {
    attributes.set(AccordionAttributes.cycledSwitching, Boolean.TRUE);

    prevItemButton.click();
    assertEquals(valueOutput.getStringValue(), "item5");

    Graphene.guardAjax(switchTo5Button).click();
    prevItemButton.click();
    assertEquals(valueOutput.getStringValue(), "item4");
  }
  public void testDisabled() {
    updateDropDownMenuInvoker();
    getCurrentMenu().advanced().show(page.getTarget1());

    dropDownMenuAttributes.set(DropDownMenuAttributes.disabled, true);

    try {
      getCurrentMenu().advanced().show(page.getTarget1());
      fail("The context menu should not be invoked when disabled!");
    } catch (TimeoutException ex) {
      // OK
    }
  }
 @Test
 @Templates(value = "plain")
 public void testColumnClasses() {
   String testedClass = "metamer-ftest-class";
   pickListAttributes.set(PickListAttributes.columnClasses, testedClass);
   for (SelectableListItem li : picklist.advanced().getSourceList().getItems()) {
     for (WebElement e : li.getRootElement().findElements(By.tagName("td"))) {
       assertTrue(
           e.getAttribute("class").contains(testedClass),
           "Item @class should contain " + testedClass);
     }
   }
 }
 @Test
 public void testResize() {
   popupPanelAttributes.set(PopupPanelAttributes.maxHeight, 420);
   popupPanelAttributes.set(PopupPanelAttributes.maxWidth, 420);
   popupPanelAttributes.set(PopupPanelAttributes.height, 400);
   popupPanelAttributes.set(PopupPanelAttributes.width, 400);
   openPopupPanel();
   int widthBefore = panel.advanced().getLocations().getWidth();
   int heightBefore = panel.advanced().getLocations().getHeight();
   Assert.assertEquals(widthBefore, 400, TOLERANCE);
   Assert.assertEquals(heightBefore, 400, TOLERANCE);
   resize.click(); // resizes by 10x10
   Assert.assertEquals(panel.advanced().getLocations().getWidth(), 410, TOLERANCE);
   Assert.assertEquals(panel.advanced().getLocations().getHeight(), 410, TOLERANCE);
   resize.click(); // resizes by 10x10
   Assert.assertEquals(panel.advanced().getLocations().getWidth(), 420, TOLERANCE);
   Assert.assertEquals(panel.advanced().getLocations().getHeight(), 420, TOLERANCE);
   resize.click(); // resizes by 10x10, resize over max width/height, width/height stays at its
   // maximum
   Assert.assertEquals(panel.advanced().getLocations().getWidth(), 420, TOLERANCE);
   Assert.assertEquals(panel.advanced().getLocations().getHeight(), 420, TOLERANCE);
 }
  public void testClickRightArrow() {
    int startValue = slider.advanced().getInput().getIntValue();
    int clicks = 1;

    inputNumberSliderAttributes.set(InputNumberSliderAttributes.showArrows, Boolean.TRUE);

    MetamerPage.waitRequest(slider, WaitRequestType.XHR).increase();

    Graphene.waitGui()
        .until("Output was not updated.")
        .element(output)
        .text()
        .equalTo(String.valueOf(startValue + clicks));
  }
 public void checkRendered() {
   messageAttributes.set(MessageAttributes.rendered, Boolean.TRUE);
   generateValidationMessagesWithWait();
   assertTrue(
       getMessageComponentForFirstInput().advanced().isVisible(), "Message should be visible.");
   assertTrue(
       getMessageComponentForSecondInput().advanced().isVisible(), "Message should be visible.");
   assertTrue(
       getMessageComponentForSelectableInput().advanced().isVisible(),
       "Message should be visible.");
   messageAttributes.set(MessageAttributes.rendered, Boolean.FALSE);
   generateValidationMessages();
   submitWithA4jBtn();
   assertFalse(
       getMessageComponentForFirstInput().advanced().isVisible(),
       "Message should not be visible.");
   assertFalse(
       getMessageComponentForSecondInput().advanced().isVisible(),
       "Message should not be visible.");
   assertFalse(
       getMessageComponentForSelectableInput().advanced().isVisible(),
       "Message should not be visible.");
 }
 public void testStyle() {
   updateDropDownMenuInvoker();
   String color = "yellow";
   String styleVal = "background-color: " + color + ";";
   dropDownMenuAttributes.set(DropDownMenuAttributes.style, styleVal);
   getCurrentMenu().advanced().show(page.getTarget1());
   String backgroundColor =
       getCurrentMenu().advanced().getTopLevelElement().getCssValue("background-color");
   // webdriver retrieves the color in rgba format
   assertEquals(
       ContextMenuSimplePage.trimTheRGBAColor(backgroundColor),
       "rgba(255,255,0,1)",
       "The style was not applied correctly!");
 }
  @Test
  @Templates("plain")
  public void testRightDisabledIcon() {
    By image = By.cssSelector(page.getRightIconSelector() + " img");

    // icon should not be locateable
    for (int i = 1; i < 6; i++) {
      try {
        driver.findElement(
            ByJQuery.selector(page.getRightIconSelector().replace("1", String.valueOf(i))));
      } catch (NoSuchElementException e) {
        // ok
      }
    }

    accordionItemAttributes.set(AccordionItemAttributes.disabled, true);

    verifyStandardIcons(
        AccordionItemAttributes.rightDisabledIcon, page.getRightDisabledIcon(), image, "-dis");
  }
  public void testHideDelay(int delay) {
    dropDownMenuAttributes.set(DropDownMenuAttributes.showDelay, 0);
    updateDropDownMenuInvoker();
    getCurrentMenu().advanced().setupHideDelay(delay);

    testDelay(
        new Action() {
          @Override
          public void perform() {
            getCurrentMenu().advanced().show(page.getTarget1());
          }
        },
        new Action() {
          @Override
          public void perform() {
            getCurrentMenu().advanced().hide();
          }
        },
        "hideDelay",
        delay);
  }
  public void testShowDelay(int delay) {
    dropDownMenuAttributes.set(DropDownMenuAttributes.hideDelay, 0);
    updateDropDownMenuInvoker();
    getCurrentMenu().advanced().setupShowDelay(delay);

    testDelay(
        new Action() {
          @Override
          public void perform() {
            try {
              getCurrentMenu().advanced().hide();
            } catch (IllegalStateException ignored) {
            }
          }
        },
        new Action() {
          @Override
          public void perform() {
            getCurrentMenu().advanced().show(page.getTarget1());
          }
        },
        "showDelay",
        delay);
  }
 @Test
 @Templates(value = "plain")
 public void testRendered() {
   menuGroupAttributes.set(MenuGroupAttributes.rendered, false);
   assertNotPresent(group, "Menu group should not be rendered when rendered=false.");
 }
 @Test
 @Templates("plain")
 public void testRendered() {
   accordionItemAttributes.set(AccordionItemAttributes.rendered, false);
   assertNotPresent(testElement, "Item1 should not be rendered when rendered=false.");
 }