Search in sources :

Example 61 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class ClearNodeChildrenIT method processContainerWithTextNodes_allNodesAreRemoved.

private void processContainerWithTextNodes_allNodesAreRemoved(String buttonToClick, String expectedMessage, String expectedInnerText) {
    TestBenchElement container = root.$(TestBenchElement.class).id("containerWithMixedChildren");
    Assert.assertThat(container.getText(), CoreMatchers.allOf(CoreMatchers.containsString("Some text 1"), CoreMatchers.containsString("Some text 2"), CoreMatchers.containsString("Some text 3")));
    List<WebElement> divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(2, divs.size());
    TestBenchElement button = root.$(TestBenchElement.class).id(buttonToClick);
    String oldTtext = message.getText();
    button.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith(expectedMessage);
    divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(0, divs.size());
    Assert.assertEquals(expectedInnerText, container.getAttribute("innerText"));
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 62 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class ClearNodeChildrenIT method processContainerWithClientAndServerSideNodes_allNodesAreRemoved_serverNodesAreDetached.

private void processContainerWithClientAndServerSideNodes_allNodesAreRemoved_serverNodesAreDetached(String buttonToClick, String expectedMessage, String expectedInnerText) {
    TestBenchElement container = root.$(TestBenchElement.class).id("containerWithElementChildren");
    List<WebElement> divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(2, divs.size());
    TestBenchElement add = root.$(TestBenchElement.class).id("addChildToContainer1");
    String oldTtext = message.getText();
    add.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith("Div 'Server div 1' attached.");
    divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(3, divs.size());
    TestBenchElement button = root.$(TestBenchElement.class).id(buttonToClick);
    oldTtext = message.getText();
    button.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith(expectedMessage);
    divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(0, divs.size());
    Assert.assertEquals(expectedInnerText, container.getAttribute("innerText"));
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 63 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class ClearNodeChildrenIT method addNodeToSlot_processContainer_allNodesAreRemoved_serverNodesAreDetached.

private void addNodeToSlot_processContainer_allNodesAreRemoved_serverNodesAreDetached(String buttonToClick, String expectedMessage, String expectedInnerText) {
    List<WebElement> divs = root.findElements(By.tagName("div"));
    Assert.assertEquals(0, divs.size());
    TestBenchElement add = root.$(TestBenchElement.class).id("addChildToSlot");
    String oldTtext = message.getText();
    add.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith("Div 'Server div 1' attached.");
    TestBenchElement button = root.$(TestBenchElement.class).id(buttonToClick);
    oldTtext = message.getText();
    button.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith(expectedMessage);
    divs = root.findElements(By.tagName("div"));
    Assert.assertEquals(0, divs.size());
    Assert.assertEquals(expectedInnerText, root.getAttribute("innerText"));
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 64 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class ClearNodeChildrenIT method processContainerWithClientSideNodes_allNodesAreRemoved.

private void processContainerWithClientSideNodes_allNodesAreRemoved(String buttonToClick, String expectedMessage, String expectedInnerText) {
    TestBenchElement container = root.$(TestBenchElement.class).id("containerWithElementChildren");
    List<WebElement> divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(2, divs.size());
    TestBenchElement button = root.$(TestBenchElement.class).id(buttonToClick);
    String oldTtext = message.getText();
    button.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith(expectedMessage);
    divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(0, divs.size());
    Assert.assertEquals(expectedInnerText, container.getAttribute("innerText"));
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 65 with TestBenchElement

use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.

the class ClearNodeChildrenIT method addTextNode_processContainerWithClientSideNodes_allNodesAreRemoved.

private void addTextNode_processContainerWithClientSideNodes_allNodesAreRemoved(String buttonToClick, String expectedMessage, String expectedInnerText) {
    TestBenchElement container = root.$(TestBenchElement.class).id("containerWithElementChildren");
    List<WebElement> divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(2, divs.size());
    TestBenchElement addTextNode = root.$(TestBenchElement.class).id("addTextNodeToContainer1");
    String oldTtext = message.getText();
    addTextNode.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith("Added 'Text node' to div with id 'containerWithElementChildren'.");
    TestBenchElement button = root.$(TestBenchElement.class).id(buttonToClick);
    oldTtext = message.getText();
    button.click();
    waitForMessageToChange(oldTtext);
    assertMessageEndsWith(expectedMessage);
    divs = container.findElements(By.tagName("div"));
    Assert.assertEquals(0, divs.size());
    Assert.assertEquals(expectedInnerText, container.getAttribute("innerText"));
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Aggregations

TestBenchElement (com.vaadin.testbench.TestBenchElement)154 Test (org.junit.Test)120 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)98 WebElement (org.openqa.selenium.WebElement)46 By (org.openqa.selenium.By)6 DivElement (com.vaadin.flow.component.html.testbench.DivElement)5 List (java.util.List)5 Assert (org.junit.Assert)5 SpanElement (com.vaadin.flow.component.html.testbench.SpanElement)4 ChromeDeviceTest (com.vaadin.flow.testutil.ChromeDeviceTest)4 NativeButtonElement (com.vaadin.flow.component.html.testbench.NativeButtonElement)3 File (java.io.File)3 Ignore (org.junit.Ignore)3 ButtonElement (com.vaadin.flow.component.button.testbench.ButtonElement)2 DevModeGizmoElement (com.vaadin.flow.testutil.DevModeGizmoElement)2 Optional (java.util.Optional)2 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)2 WebDriver (org.openqa.selenium.WebDriver)2 ParagraphElement (com.vaadin.flow.component.html.testbench.ParagraphElement)1 TextFieldElement (com.vaadin.flow.component.textfield.testbench.TextFieldElement)1