Search in sources :

Example 46 with TestBenchElement

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

the class ApplicationThemeComponentIT method validateEmbeddedComponent.

private void validateEmbeddedComponent(TestBenchElement themedComponent, String target) {
    Assert.assertEquals(target + " didn't contain the background image", "url(\"" + getRootURL() + "/VAADIN/static/themes/embedded-theme/img/bg.jpg\")", themedComponent.getCssValue("background-image"));
    Assert.assertEquals(target + " didn't contain font-family", "Ostrich", themedComponent.getCssValue("font-family"));
    final TestBenchElement embeddedComponent = themedComponent.$(DivElement.class).id(EMBEDDED_ID);
    final SpanElement handElement = embeddedComponent.$(SpanElement.class).id(HAND_ID);
    Assert.assertEquals("Color should have been applied", "rgba(0, 128, 0, 1)", handElement.getCssValue("color"));
}
Also used : SpanElement(com.vaadin.flow.component.html.testbench.SpanElement) DivElement(com.vaadin.flow.component.html.testbench.DivElement) TestBenchElement(com.vaadin.testbench.TestBenchElement)

Example 47 with TestBenchElement

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

the class BasicsIT method applicationStarts.

@Test
public void applicationStarts() {
    TestBenchElement header = $("h2").first();
    Assert.assertEquals("This place intentionally left empty", header.getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test)

Example 48 with TestBenchElement

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

the class ContextPathIT method applicationStarts.

@Test
public void applicationStarts() {
    TestBenchElement header = $("h2").first();
    Assert.assertEquals("Hello world!", header.getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 49 with TestBenchElement

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

the class ThemeReloadIT method updateStyle_changeIsReloaded.

@Test
@Ignore
public void updateStyle_changeIsReloaded() throws IOException {
    TestBenchElement header = $("h2").first();
    Assert.assertEquals("rgba(0, 0, 255, 1)", header.getCssValue("color"));
    File baseDir = new File(System.getProperty("user.dir", "."));
    File themeFolder = new File(baseDir, "frontend/themes/vite-basics/");
    File stylesCss = new File(themeFolder, "styles.css");
    final String stylesContent = FileUtils.readFileToString(stylesCss, StandardCharsets.UTF_8);
    try {
        FileUtils.write(stylesCss, stylesContent + "\nh2 { color: rgba(255, 0, 0, 1); }", StandardCharsets.UTF_8.name());
        waitUntil(webDriver -> webDriver.findElement(By.tagName("h2")).getCssValue("color").equals("rgba(255, 0, 0, 1)"), 30);
        header = $("h2").first();
        Assert.assertEquals("rgba(255, 0, 0, 1)", header.getCssValue("color"));
    } finally {
        FileUtils.write(stylesCss, stylesContent, StandardCharsets.UTF_8.name());
    }
}
Also used : File(java.io.File) TestBenchElement(com.vaadin.testbench.TestBenchElement) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 50 with TestBenchElement

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

the class ProductionBasicsIT method imageFromThemeShown.

@Test
public void imageFromThemeShown() {
    getDriver().get(getRootURL());
    waitForDevServer();
    TestBenchElement img = $("img").id(MainView.PLANT);
    waitUntil(driver -> {
        String heightString = (String) executeScript("return getComputedStyle(arguments[0]).height.replace('px','')", img);
        float height = Float.parseFloat(heightString);
        return (height > 150);
    });
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

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