Search in sources :

Example 51 with TestBenchElement

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

the class IdTestIT method testIds.

@Test
public void testIds() {
    open();
    checkLogsForErrors(msg -> msg.contains("sockjs-node") || msg.contains("[WDS]"));
    waitUntilWithMessage(ExpectedConditions.presenceOfElementLocated(By.tagName("my-component")), "Failed to load my-component", 25);
    TestBenchElement myComponent = $("my-component").first();
    // wait for polymer initalisation
    waitUntillWithMessage(driver -> getCommandExecutor().executeScript("return !!window.Polymer || !!arguments[0].constructor.polymerElementVersion", myComponent), "Failed to load constructor.polymerElementVersion for 'my-component'");
    waitUntillWithMessage(driver -> getCommandExecutor().executeScript("return arguments[0].$ !== undefined", myComponent), "Failed to load $ for 'my-component'");
    WebElement content = myComponent.$(TestBenchElement.class).id("content");
    Assert.assertEquals("", content.getText());
    WebElement button = myComponent.$(TestBenchElement.class).id("button");
    button.click();
    Assert.assertEquals("1", content.getText());
    button.click();
    Assert.assertEquals("2", content.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 52 with TestBenchElement

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

the class ThemedVariantComponentIT method servletPageGetsWebComponent_attributeIsReflectedToServer.

@Test
public void servletPageGetsWebComponent_attributeIsReflectedToServer() {
    open();
    TestBenchElement webComponent = $("themed-variant-web-component").first();
    Assert.assertEquals("dark", webComponent.getAttribute("theme"));
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 53 with TestBenchElement

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

the class InnerTemplateVisibilityIT method innerTemplateIsHiddenWithDisplayNone.

@Test
public void innerTemplateIsHiddenWithDisplayNone() {
    open();
    // when inner is hidden
    NativeButtonElement toggleButton = $(NativeButtonElement.class).id(InnerTemplateVisibilityView.TOGGLE_INNER_VISIBILITY_BUTTON_ID);
    toggleButton.click();
    // then: element is not visible, attribute 'hidden' and 'display: none'
    // set
    TestBenchElement outer = $("*").id(InnerTemplateVisibilityView.OUTER_ID);
    TestBenchElement inner = outer.$("*").id(InnerTemplateVisibilityView.INNER_ID);
    Assert.assertFalse("expected inner to be hidden", inner.isDisplayed());
    Assert.assertNotNull("expected attribute hidden on inner", inner.getAttribute("hidden"));
    Assert.assertEquals("expected 'display: none' on inner", "none", inner.getCssValue("display"));
}
Also used : NativeButtonElement(com.vaadin.flow.component.html.testbench.NativeButtonElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 54 with TestBenchElement

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

the class InjectedElementInsideMixinBehaviorIT method injectedByIdWorksWitinMixins.

@Test
public void injectedByIdWorksWitinMixins() {
    open();
    TestBenchElement template = $("mixin-injects").first();
    WebElement injected = template.$(TestBenchElement.class).id("injected");
    Assert.assertEquals("foo", injected.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 55 with TestBenchElement

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

the class MutationSeveralSyncedPropsIT method twoSynchronizedPropertiesSimultensousUpdate_bothAreUpdated.

@Test
public void twoSynchronizedPropertiesSimultensousUpdate_bothAreUpdated() {
    open();
    TestBenchElement template = $(TestBenchElement.class).id("template");
    WebElement name = template.$(TestBenchElement.class).id("name");
    WebElement msg = template.$(TestBenchElement.class).id("msg");
    Assert.assertEquals("foo", name.getText());
    Assert.assertEquals("msg", msg.getText());
    findElement(By.id("update")).click();
    Assert.assertEquals("bar", name.getText());
    Assert.assertEquals("baz", msg.getText());
}
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