Esempio n. 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());
 }
  @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"));
  }
  private List<String> getFilterSuggestions(String string) {
    ComboBoxElement comboBox = $(ComboBoxElement.class).first();
    comboBox.findElement(By.vaadin("#textbox")).sendKeys(string);

    return comboBox.getPopupSuggestions();
  }
 protected void waitForApplication() {
   if (!isElementPresent(UIElement.class)) {
     // Wait for UI element.
     waitForElementPresent(By.vaadin("//com.vaadin.ui.UI"));
   }
 }