예제 #1
0
 @Test
 public void testCase1() throws Exception {
   driver.get(concatUrl(baseUrl, "/book-examples/tobetested?restartApplication"));
   driver.findElement(By.vaadin("bookexamplestobetested::PID_Smain.button/domChild[0]")).click();
   assertEquals(
       "This is different!",
       driver
           .findElement(
               By.vaadin(
                   "bookexamplestobetested::/VVerticalLayout[0]/ChildComponentContainer[1]/VLabel[0]"))
           .getText());
 }
예제 #2
0
  @Test
  public void testCustomStyleShouldStayAfterMenuSelect() {
    openTestURL();

    $(ButtonElement.class).caption("Add styles").first().click();

    MenuBarElement menu = $(MenuBarElement.class).first();
    List<WebElement> elements = menu.findElements(By.className("custom-menu-item"));
    Assert.assertEquals(2, elements.size());

    menu.clickItem("first");
    menu.clickItem("second");
    elements = menu.findElements(By.className("custom-menu-item"));
    Assert.assertEquals(2, elements.size());
  }
  @Test
  public void testComboBoxSuggestionsListedCorrectly() throws Exception {
    openTestURL();
    $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox")).sendKeys("rus", Keys.ENTER);

    List<String> result = new ArrayList<>();

    // pick list items that are shown in suggestion popup
    List<WebElement> elems = findElements(By.cssSelector("td[role=\"listitem\"]"));
    Assert.assertEquals("not enough suggestions shown", DATA.length, elems.size());

    for (WebElement elem : elems) {
      result.add(elem.getText());
    }

    Assert.assertArrayEquals("popup items not what they should be", DATA, result.toArray());
  }
  @Test
  public void testNewValueIsClearedAppropriately() throws InterruptedException {
    setDebug(true);
    openTestURL();

    WebElement element = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox"));
    ((TestBenchElementCommands) element).click(8, 7);
    element.clear();
    element.sendKeys("New value");
    assertEquals("New value", element.getAttribute("value"));
    if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) {
      new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
      Thread.sleep(500);
    } else {
      element.sendKeys(Keys.RETURN);
    }

    assertEquals("", element.getAttribute("value"));
  }
예제 #5
0
  private List<String> getFilterSuggestions(String string) {
    ComboBoxElement comboBox = $(ComboBoxElement.class).first();
    comboBox.findElement(By.vaadin("#textbox")).sendKeys(string);

    return comboBox.getPopupSuggestions();
  }
예제 #6
0
 private WebElement getTooltipContainerElement() {
   return getDriver().findElement(By.className("v-tooltip"));
 }
예제 #7
0
 @Override
 public String getCaption() {
   WebElement captElem = findElement(By.className("v-button-caption"));
   return captElem.getText();
 }
 protected void waitForApplication() {
   if (!isElementPresent(UIElement.class)) {
     // Wait for UI element.
     waitForElementPresent(By.vaadin("//com.vaadin.ui.UI"));
   }
 }
 private List<WebElement> getVisibleEvents(WebElement dayWithEvents) {
   return dayWithEvents.findElements(By.className("v-calendar-event"));
 }
 private WebElement toggleExpandEvents(WebElement dayWithEvents) {
   return dayWithEvents.findElement(By.className("v-calendar-bottom-spacer"));
 }
 @Override
 protected WebElement getMenuElement(String menuCaption) {
   return getDriver().findElement(By.xpath("//td[text() = '" + menuCaption + "']"));
 }