Search in sources :

Example 1 with NativeButtonElement

use of com.vaadin.flow.component.html.testbench.NativeButtonElement in project flow by vaadin.

the class InnerTemplateVisibilityIT method outerTemplateIsHiddenWithAttributeOnly.

@Test
public void outerTemplateIsHiddenWithAttributeOnly() {
    open();
    // when hidden
    NativeButtonElement toggleButton = $(NativeButtonElement.class).id(InnerTemplateVisibilityView.TOGGLE_OUTER_VISIBILITY_BUTTON_ID);
    toggleButton.click();
    // then: element is not visible, attribute 'hidden' is set but
    // 'display: none' is not set
    WebElement outer = findElement(By.id(InnerTemplateVisibilityView.OUTER_ID));
    Assert.assertFalse("expected outer to be hidden", outer.isDisplayed());
    Assert.assertNotNull("expected attribute hidden on outer", outer.getAttribute("hidden"));
    Assert.assertEquals("expected no style attribute", "", outer.getAttribute("style"));
}
Also used : NativeButtonElement(com.vaadin.flow.component.html.testbench.NativeButtonElement) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 2 with NativeButtonElement

use of com.vaadin.flow.component.html.testbench.NativeButtonElement 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 3 with NativeButtonElement

use of com.vaadin.flow.component.html.testbench.NativeButtonElement in project flow by vaadin.

the class SimpleLitTemplateShadowRootIT method clientPropertyAndCallbackWorks.

@Test
public void clientPropertyAndCallbackWorks() {
    NativeButtonElement clientButton = template.$(NativeButtonElement.class).id("clientButton");
    Assert.assertEquals("Client button", clientButton.getText());
    clientButton.click();
    DivElement label = template.$(DivElement.class).id("label");
    Assert.assertEquals("Hello from ClientCallable", label.getText());
}
Also used : DivElement(com.vaadin.flow.component.html.testbench.DivElement) NativeButtonElement(com.vaadin.flow.component.html.testbench.NativeButtonElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 4 with NativeButtonElement

use of com.vaadin.flow.component.html.testbench.NativeButtonElement in project flow by vaadin.

the class InnerTemplateVisibilityIT method innerTemplateDisplayStyleRestored.

@Test
public void innerTemplateDisplayStyleRestored() {
    open();
    // when inner is hidden and unhidden
    NativeButtonElement toggleButton = $(NativeButtonElement.class).id(InnerTemplateVisibilityView.TOGGLE_INNER_VISIBILITY_BUTTON_ID);
    toggleButton.click();
    toggleButton.click();
    // then: element is visible, attribute and 'display: none' are no longer
    // present
    TestBenchElement outer = $("*").id(InnerTemplateVisibilityView.OUTER_ID);
    TestBenchElement inner = outer.$("*").id(InnerTemplateVisibilityView.INNER_ID);
    Assert.assertTrue("expected inner to be visible", inner.isDisplayed());
    Assert.assertNull("inner should not have attribute hidden", inner.getAttribute("hidden"));
    Assert.assertEquals("expected 'display: block' on inner", "block", 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 5 with NativeButtonElement

use of com.vaadin.flow.component.html.testbench.NativeButtonElement in project flow by vaadin.

the class SimpleLitTemplateShadowRootIT method idMappingWorks.

@Test
public void idMappingWorks() {
    NativeButtonElement mappedButton = template.$(NativeButtonElement.class).id("mappedButton");
    Assert.assertEquals("Server button", mappedButton.getText());
    mappedButton.click();
    DivElement label = template.$(DivElement.class).id("label");
    Assert.assertEquals("Hello from server component event listener", label.getText());
    DivElement sortDiv = template.$(DivElement.class).id("sort");
    Assert.assertEquals("Sort", sortDiv.getText());
}
Also used : DivElement(com.vaadin.flow.component.html.testbench.DivElement) NativeButtonElement(com.vaadin.flow.component.html.testbench.NativeButtonElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Aggregations

NativeButtonElement (com.vaadin.flow.component.html.testbench.NativeButtonElement)5 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)5 Test (org.junit.Test)5 DivElement (com.vaadin.flow.component.html.testbench.DivElement)2 TestBenchElement (com.vaadin.testbench.TestBenchElement)2 WebElement (org.openqa.selenium.WebElement)1