Search in sources :

Example 91 with TestBenchElement

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

the class AttachExistingElementByIdIT method assertTemplate.

private void assertTemplate(String id, String initialLabelText, String placeholder) {
    TestBenchElement template = $("*").id(id);
    WebElement input = getInput(template);
    Assert.assertEquals(initialLabelText, getLabel(template).getText());
    Assert.assertEquals(placeholder, input.getAttribute("placeholder"));
    input.sendKeys("Harley!");
    input.sendKeys(Keys.ENTER);
    Assert.assertEquals("Text from input Harley!", getLabel(template).getText());
    // Reset values to defaults
    $(TestBenchElement.class).id(id).$(TestBenchElement.class).id("button").click();
    Assert.assertEquals("default", getLabel(template).getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 92 with TestBenchElement

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

the class ExportedJSFunctionIT method poll.

private void poll() {
    TestBenchElement counter = $(TestBenchElement.class).id("pollCounter");
    TestBenchElement pollTrigger = $(TestBenchElement.class).id("poll");
    Assert.assertEquals("No polls", counter.getText());
    pollTrigger.click();
    Assert.assertEquals("Poll called 1 times", counter.getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 93 with TestBenchElement

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

the class ReusableThemeIT method componentThemeIsApplied.

@Test
public void componentThemeIsApplied() {
    open();
    TestBenchElement myField = $(TestBenchElement.class).id(MY_COMPONENT_ID);
    TestBenchElement input = myField.$("vaadin-input-container").attribute("part", "input-field").first();
    Assert.assertEquals("Polymer text field should have red background", "rgba(255, 0, 0, 1)", input.getCssValue("background-color"));
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 94 with TestBenchElement

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

the class NavigateBetweenViewsIT method openTsView_navigateToFlowView_isConnectedOnAttach.

@Test
public void openTsView_navigateToFlowView_isConnectedOnAttach() {
    getDriver().get(getRootURL() + "/");
    waitForDevServer();
    waitUntil(input -> $("about-view").first().$("a").id("navigate-hello").isDisplayed());
    TestBenchElement aboutView = $("about-view").first();
    aboutView.$("*").id("navigate-hello").click();
    getCommandExecutor().waitForVaadin();
    assertIsConnected();
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 95 with TestBenchElement

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

the class NavigateBetweenViewsIT method openTsView_navigateToFlow_navigationSuccessful.

@Test
public void openTsView_navigateToFlow_navigationSuccessful() {
    getDriver().get(getRootURL() + "/");
    waitForDevServer();
    // Wait for component inside shadowroot as there is no vaadin
    // to wait for as with server-side
    waitUntil(input -> $("about-view").first().$("a").id("navigate-hello").isDisplayed());
    TestBenchElement aboutView = $("about-view").first();
    aboutView.$("*").id("navigate-hello").click();
    getCommandExecutor().waitForVaadin();
    Assert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/hello"));
    Assert.assertTrue("Missing expected native button on page", $(NativeButtonElement.class).id(NAVIGATE_ABOUT).isDisplayed());
}
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)

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