Search in sources :

Example 11 with TestBenchElement

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

the class TemplateHasInjectedSubTemplateIT method injectedSubTemplate_injectedInstanceWorks.

@Test
public void injectedSubTemplate_injectedInstanceWorks() throws InterruptedException {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    TestBenchElement child = template.$(TestBenchElement.class).id("child");
    TestBenchElement text = child.$(TestBenchElement.class).id("text");
    Assert.assertEquals("foo", text.getText());
    template.$(TestBenchElement.class).id("button").click();
    waitUntil(driver -> "bar".equals(text.getText()));
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 12 with TestBenchElement

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

the class TemplateInTemplateWithIdIT method childTemplateInstanceHandlesEvent.

@Test
public void childTemplateInstanceHandlesEvent() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    TestBenchElement child = template.$(TestBenchElement.class).id("child");
    WebElement text = child.$(TestBenchElement.class).id("text");
    Assert.assertEquals("@Id injected!", 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 13 with TestBenchElement

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

the class TemplatesVisibilityIT method grandParentVisibility_descendantsAreBound.

@Test
public void grandParentVisibility_descendantsAreBound() {
    open();
    TestBenchElement grandParent = $("js-grand-parent").first();
    TestBenchElement subTemplate = grandParent.$("js-sub-template").first();
    // Check child and grand child property values. They shouldn't be set
    // since the elements are not bound
    TestBenchElement subTemplateProp = subTemplate.$(TestBenchElement.class).id("prop");
    TestBenchElement grandChild = subTemplate.$(TestBenchElement.class).id("js-grand-child");
    WebElement grandChildFooProp = grandChild.$(TestBenchElement.class).id("foo-prop");
    WebElement grandChildProp = assertInitialPropertyValues(subTemplateProp, grandChild, grandChildFooProp);
    // make parent visible
    findElement(By.id("grand-parent-visibility")).click();
    // now all descendants should be bound and JS is executed for the
    // grandchild
    assertBound(subTemplateProp, grandChildFooProp, grandChildProp);
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 14 with TestBenchElement

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

the class TemplatesVisibilityIT method subTemplateVisibility_grandChildIsBound.

@Test
public void subTemplateVisibility_grandChildIsBound() {
    open();
    TestBenchElement grandParent = $("js-grand-parent").first();
    TestBenchElement subTemplate = grandParent.$("js-sub-template").first();
    // make sub template invisible
    findElement(By.id("sub-template-visibility")).click();
    // nothing has changed: parent is not bound -> descendants are still not
    // bound
    TestBenchElement subTemplateProp = subTemplate.$(TestBenchElement.class).id("prop");
    TestBenchElement grandChild = subTemplate.$(TestBenchElement.class).id("js-grand-child");
    WebElement grandChildFooProp = grandChild.$(TestBenchElement.class).id("foo-prop");
    assertInitialPropertyValues(subTemplateProp, grandChild, grandChildFooProp);
    // make parent visible
    findElement(By.id("grand-parent-visibility")).click();
    // sub template is invisible now, again: all properties have no values
    WebElement grandChildProp = assertInitialPropertyValues(subTemplateProp, grandChild, grandChildFooProp);
    // make sub template visible
    findElement(By.id("sub-template-visibility")).click();
    // now everything is bound
    assertBound(subTemplateProp, grandChildFooProp, grandChildProp);
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 15 with TestBenchElement

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

the class TemplatesVisibilityIT method grandChildVisibility_grandChildIsBound.

@Test
public void grandChildVisibility_grandChildIsBound() {
    open();
    TestBenchElement grandParent = $("js-grand-parent").first();
    TestBenchElement subTemplate = grandParent.$("js-sub-template").first();
    // make grand child template invisible
    findElement(By.id("grand-child-visibility")).click();
    // nothing has changed: parent is not bound -> descendants are still not
    // bound
    TestBenchElement subTemplateProp = subTemplate.$(TestBenchElement.class).id("prop");
    TestBenchElement grandChild = subTemplate.$(TestBenchElement.class).id("js-grand-child");
    WebElement grandChildFooProp = grandChild.$(TestBenchElement.class).id("foo-prop");
    assertInitialPropertyValues(subTemplateProp, grandChild, grandChildFooProp);
    // make grand parent visible
    findElement(By.id("grand-parent-visibility")).click();
    // grand child template is invisible now, again: all its properties have
    // no values
    WebElement grandChildProp = grandChild.$(TestBenchElement.class).id("prop");
    Assert.assertNotEquals("bar", grandChildFooProp.getText());
    Assert.assertNotEquals("foo", grandChildProp.getText());
    // make grand child template visible
    findElement(By.id("grand-child-visibility")).click();
    // now everything is bound
    assertBound(subTemplateProp, grandChildFooProp, grandChildProp);
}
Also used : WebElement(org.openqa.selenium.WebElement) 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