Search in sources :

Example 56 with TestBenchElement

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

the class PolymerDefaultPropertyValueIT method initialModelValues_polymerHasDefaultValues.

@Test
public void initialModelValues_polymerHasDefaultValues() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    TestBenchElement text = template.$(TestBenchElement.class).id("text");
    Assert.assertEquals("foo", text.getText());
    TestBenchElement name = template.$(TestBenchElement.class).id("name");
    Assert.assertEquals("bar", name.getText());
    TestBenchElement msg = template.$(TestBenchElement.class).id("message");
    Assert.assertEquals("updated-message", msg.getText());
    TestBenchElement email = template.$(TestBenchElement.class).id("email");
    Assert.assertEquals("foo@example.com", email.getText());
    findElement(By.id("show-email")).click();
    WebElement serverSideEmailValue = findElement(By.id("email-value"));
    Assert.assertEquals("foo@example.com", serverSideEmailValue.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 57 with TestBenchElement

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

the class PolymerPropertiesIT method propertyAdd_propertyBecomesAvailable.

@Test
public void propertyAdd_propertyBecomesAvailable() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    template.$(TestBenchElement.class).id("set-property").click();
    TestBenchElement name = template.$(TestBenchElement.class).id("name");
    Assert.assertEquals("foo", name.getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 58 with TestBenchElement

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

the class PolymerPropertyMutationInObserverIT method property_mutation_inside_observers_synced_correctly.

@Test
public void property_mutation_inside_observers_synced_correctly() {
    open();
    List<WebElement> modelValueDivs = findElements(By.className("model-value"));
    Assert.assertEquals("Value changed twice initially", 2, modelValueDivs.size());
    Assert.assertEquals("First value change should equal the initially set server side value", "Event old value: null, event value: initially set value, current model value: initially set value", modelValueDivs.get(0).getText());
    Assert.assertEquals("Observer mutation has been transmitted to the server", "Event old value: initially set value, event value: mutated, current model value: mutated", modelValueDivs.get(1).getText());
    TestBenchElement template = $(TestBenchElement.class).id("template");
    template.$(TestBenchElement.class).id("input").sendKeys(Keys.BACK_SPACE);
    modelValueDivs = findElements(By.className("model-value"));
    Assert.assertEquals("Value changed 4 times in total after backspace", 4, modelValueDivs.size());
    Assert.assertEquals("User action mutation synced to server", "Event old value: mutated, event value: mutate, current model value: mutated", modelValueDivs.get(2).getText());
    Assert.assertEquals("Observer mutation acting on the user action mutation synced to server", "Event old value: mutate, event value: mutated, current model value: mutated", modelValueDivs.get(3).getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 59 with TestBenchElement

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

the class BeanInListingIT method assertSelectionValue.

private void assertSelectionValue(String className, WebElement selected, String item) {
    TestBenchElement template = $(TestBenchElement.class).id("template");
    List<TestBenchElement> items = template.$(TestBenchElement.class).attribute("class", className).all();
    items.stream().filter(itemElement -> itemElement.getText().equals(item)).findFirst().get().click();
    waitUntil(new SelectedCondition(selected, item));
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) List(java.util.List) WebDriver(org.openqa.selenium.WebDriver) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 60 with TestBenchElement

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

the class BasicTypeInListIT method basicTypeInModeList.

@Test
public void basicTypeInModeList() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    List<TestBenchElement> items = template.$(TestBenchElement.class).attribute("class", "item").all();
    Assert.assertEquals(2, items.size());
    Assert.assertEquals("foo", items.get(0).getText());
    Assert.assertEquals("bar", items.get(1).getText());
    findElement(By.id("add")).click();
    items = template.$(TestBenchElement.class).attribute("class", "item").all();
    Assert.assertEquals(3, items.size());
    Assert.assertEquals("newItem", items.get(2).getText());
    findElement(By.id("remove")).click();
    items = template.$(TestBenchElement.class).attribute("class", "item").all();
    Assert.assertEquals(2, items.size());
    Assert.assertEquals("bar", items.get(0).getText());
}
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