Search in sources :

Example 86 with TestBenchElement

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

the class ThemeIT 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 87 with TestBenchElement

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

the class ThemeIT method typeScriptCssImport_stylesAreApplied.

@Test
public void typeScriptCssImport_stylesAreApplied() {
    getDriver().get(getRootURL() + "/path/hello");
    checkLogsForErrors();
    final TestBenchElement helloWorld = $(TestBenchElement.class).first().findElement(By.tagName("hello-world-view"));
    Assert.assertEquals("hello-world-view", helloWorld.getTagName());
    Assert.assertEquals("CSS was not applied as background color was not as expected.", "rgba(255, 165, 0, 1)", helloWorld.getCssValue("background-color"));
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 88 with TestBenchElement

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

the class SendMultibyteCharactersTest method transportSupportsMultibyteCharacters.

@Test
public void transportSupportsMultibyteCharacters() {
    open();
    TestBenchElement textArea = $(TestBenchElement.class).id("text");
    StringBuilder text = new StringBuilder();
    for (int i = 0; i < 20; i++) {
        text.append("之は日本語です、テストです。");
    }
    /*
         * clean up logs up to the current state
         */
    getBrowserLogs(true);
    textArea.sendKeys(text.toString());
    textArea.sendKeys(Keys.TAB);
    findElement(By.id("label")).click();
    List<String> messages = new ArrayList<>();
    waitUntil(driver -> getBrowserLogs(true).stream().filter(String.class::isInstance).anyMatch(msg -> {
        messages.add(msg.toString());
        return msg.equals("Handling message from server");
    }), 15);
    checkLogsForErrors(msg -> msg.contains("sockjs-node") || msg.contains("[WDS]"));
    Assert.assertTrue(messages.stream().anyMatch(msg -> msg.startsWith("Received ") && msg.contains("message:")));
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) List(java.util.List) Keys(org.openqa.selenium.Keys) By(org.openqa.selenium.By) Test(org.junit.Test) PushTests(com.vaadin.flow.testcategory.PushTests) Assert(org.junit.Assert) Category(org.junit.experimental.categories.Category) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test)

Example 89 with TestBenchElement

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

the class AppViewIT method should_beAble_toLogin_usingSpringForm.

@Test
public void should_beAble_toLogin_usingSpringForm() {
    // Login by using the Spring Login Form
    openTestUrl("/login");
    TestBenchElement container = $("div").attributeContains("class", "container").first();
    container.$(TestBenchElement.class).id("username").sendKeys("admin");
    container.$(TestBenchElement.class).id("password").sendKeys("admin");
    container.$("button").first().click();
    // Wait for the server connect response
    testComponent = $("test-component").first();
    content = testComponent.$(TestBenchElement.class).id("content");
    // Verify admin calls
    verifyCallingAdminService("Hello, admin!");
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 90 with TestBenchElement

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

the class RouterLinksIT method handleEventOnServer.

@Test
public void handleEventOnServer() {
    open();
    String originalUrl = getDriver().getCurrentUrl();
    WebElement textInput = $(TestBenchElement.class).id("template").$(TestBenchElement.class).id("input");
    Assert.assertTrue("Input was not empty", textInput.getAttribute("value").isEmpty());
    textInput.sendKeys(TEXT_INPUT);
    Assert.assertEquals("Input was missing contents", TEXT_INPUT, textInput.getAttribute("value"));
    List<TestBenchElement> links = $(TestBenchElement.class).id("template").$("a").all();
    WebElement link = links.stream().filter(lnk -> lnk.getText().equals("Navigate")).findFirst().get();
    getCommandExecutor().executeScript("return arguments[0].click()", link);
    // Original url should end with UI and the navigation link Template
    Assert.assertNotEquals(originalUrl, getDriver().getCurrentUrl());
    textInput = $(TestBenchElement.class).id("template").$(TestBenchElement.class).id("input");
    Assert.assertEquals("Input didn't keep content through navigation", TEXT_INPUT, textInput.getAttribute("value"));
}
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