Search in sources :

Example 16 with TestBenchElement

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

the class UpdatableModelPropertiesIT method assertNoUpdate.

private void assertNoUpdate(String unexpectedValue) {
    waitUpdate();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    WebElement value = template.$(TestBenchElement.class).id("property-value");
    Assert.assertNotEquals(unexpectedValue, value.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 17 with TestBenchElement

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

the class UpdatableModelPropertiesIT method assertUpdate.

private void assertUpdate(String expectedValue) {
    waitUpdate();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    WebElement value = template.$(TestBenchElement.class).id("property-value");
    Assert.assertEquals(expectedValue, value.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 18 with TestBenchElement

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

the class TwoWayPolymerBindingIT method initialModelValueIsPresentAndModelUpdatesNormally.

@Test
public void initialModelValueIsPresentAndModelUpdatesNormally() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    WebElement input = template.$(TestBenchElement.class).id("input");
    // The initial client-side value should be sent from the client to the
    // model
    waitUntil(driver -> "Value: foo".equals(getStatusMessage()));
    // now make explicit updates from the client side
    input.clear();
    input.sendKeys("a");
    Assert.assertEquals("Value: a", getStatusMessage());
    input.sendKeys("b");
    Assert.assertEquals("Value: ab", getStatusMessage());
    // Reset the model value from the server-side
    template.$(TestBenchElement.class).id("reset").click();
    Assert.assertEquals("Value:", getStatusMessage());
    Assert.assertEquals("", getValueProperty(input));
    input.sendKeys("c");
    Assert.assertEquals("Value: c", getStatusMessage());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 19 with TestBenchElement

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

the class ListInsideListBindingIT method checkMessagesRemoval.

private void checkMessagesRemoval(TestBenchElement template, int initialSize) {
    for (int i = 0; i < initialSize; i++) {
        List<TestBenchElement> currentMessages = template.$(TestBenchElement.class).attribute("class", "submsg").all();
        Assert.assertEquals("Wrong amount of nested messages", initialSize - i, currentMessages.size());
        WebElement messageToRemove = currentMessages.iterator().next();
        String messageToRemoveText = messageToRemove.getText();
        messageToRemove.click();
        String removedMessageLabelText = template.$(TestBenchElement.class).id("removedMessage").getText();
        Assert.assertEquals("Expected removed message text to appear", "Removed message: " + messageToRemoveText, removedMessageLabelText);
    }
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 20 with TestBenchElement

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

the class ListInsideListBindingIT method listDataBinding.

@Test
public void listDataBinding() {
    int initialSize = 4;
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    checkMessagesRemoval(template, initialSize);
    template.$(TestBenchElement.class).id("reset").click();
    checkAllElementsUpdated(template, initialSize);
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

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