Search in sources :

Example 21 with TestBenchElement

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

the class LazyWidgetIT method lazyLoadedPolymerTemplateWorksAsElement.

@Test
public void lazyLoadedPolymerTemplateWorksAsElement() {
    open();
    // template is lazy loaded,
    waitForElementVisible(By.id("template"));
    // need some time to load
    TestBenchElement template = $(TestBenchElement.class).id("template");
    String input = "InputMaster";
    Assert.assertFalse("No greeting should be present before we press the button", template.$("*").attribute("id", "greeting").exists());
    template.$(TestBenchElement.class).id("input").sendKeys(input);
    template.$(TestBenchElement.class).id("button").click();
    Assert.assertEquals("Greeting is different from expected", String.format(LazyWidgetView.GREETINGS_TEMPLATE, input), template.$(TestBenchElement.class).id("greeting").getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 22 with TestBenchElement

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

the class PolymerModelPropertiesIT method propertySyncWithModel.

@Test
public void propertySyncWithModel() {
    open();
    WebElement initial = findElement(By.id("property-value"));
    Assert.assertEquals("Property value:foo, model value: foo", initial.getText());
    TestBenchElement template = $(TestBenchElement.class).id("template");
    TestBenchElement input = template.$(TestBenchElement.class).id("input");
    input.clear();
    input.sendKeys("x" + Keys.TAB);
    // property update event comes immediately
    List<WebElement> propertyUpdates = findElements(By.id("property-update-event"));
    WebElement propertyUpdate = propertyUpdates.get(propertyUpdates.size() - 1);
    Assert.assertEquals("Property value:x, model value: x", propertyUpdate.getText());
    // now move focus out of the input and check that value change event is
    // fired
    propertyUpdate.click();
    List<WebElement> valueUpdates = findElements(By.id("value-update"));
    WebElement valueUpdate = valueUpdates.get(valueUpdates.size() - 1);
    Assert.assertEquals("Property value:x, model value: x", valueUpdate.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 23 with TestBenchElement

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

the class TemplateInTemplateIT method childTemplateInstanceHandlesEvent.

@Test
public void childTemplateInstanceHandlesEvent() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    TestBenchElement child = template.$(TestBenchElement.class).id("child");
    child.getPropertyElement("shadowRoot", "firstElementChild").click();
    Assert.assertTrue(isElementPresent(By.id("click-handler")));
    WebElement text = child.$(TestBenchElement.class).id("text");
    Assert.assertEquals("foo", text.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 24 with TestBenchElement

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

the class TemplateMappingDetectorIT method assertMappedComponentsAreMarkedProperly.

private void assertMappedComponentsAreMarkedProperly(TestBenchElement container, boolean templateInTemplate) {
    TestBenchElement mappedComponent = container.$(TestBenchElement.class).id("detector1");
    Assert.assertEquals("Template mapped: true", mappedComponent.getText());
    TestBenchElement standaloneComponent = container.$(TestBenchElement.class).id("detector2");
    Assert.assertEquals("Template mapped: false", standaloneComponent.getText());
    TestBenchElement standaloneComposite = container.$(TestBenchElement.class).id("detector3");
    Assert.assertEquals("Composite template mapped: false Template mapped: false", standaloneComposite.getText());
    TestBenchElement theTemplateItself = container.$(TestBenchElement.class).id("detector4");
    Assert.assertEquals("The template itself: " + templateInTemplate, theTemplateItself.getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 25 with TestBenchElement

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

the class TemplateWithConnectedCallbacksIT method assertMessageIsWrittenFromServer.

private void assertMessageIsWrittenFromServer() {
    waitForElementPresent(By.tagName("template-with-connected-callbacks"));
    TestBenchElement element = $("template-with-connected-callbacks").first();
    TestBenchElement messageElement = element.$(TestBenchElement.class).id("connectedMessage");
    Assert.assertEquals("Connected (checked from server side)", messageElement.getText());
}
Also used : 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