Search in sources :

Example 1 with TestBenchElement

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

the class ComponentAddedViaInitListenerIT method componentAddedViaInitListenerIsLoaded.

@Test
public void componentAddedViaInitListenerIsLoaded() {
    open();
    TestBenchElement component = $("init-listener-component").first();
    TestBenchElement div = component.$("div").first();
    org.junit.Assert.assertEquals("Init Listener Component", div.getText());
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 2 with TestBenchElement

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

the class MultipleNpmPackageAnnotationsIT method pageShouldContainTwoPaperComponents.

@Test
public void pageShouldContainTwoPaperComponents() {
    TestBenchElement paperInput = $("paper-input").first();
    TestBenchElement paperCheckbox = $("paper-checkbox").first();
    // check that elements are on the page
    Assert.assertNotNull(paperInput);
    Assert.assertNotNull(paperCheckbox);
    // verify that the paper components are upgraded
    Assert.assertNotNull(paperInput.$("paper-input-container"));
    Assert.assertNotNull(paperCheckbox.$("checkboxContainer"));
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 3 with TestBenchElement

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

the class SessionValueIT method sessionValuePreservedOnReload.

@Test
public void sessionValuePreservedOnReload() throws InterruptedException {
    open();
    TestBenchElement div = $("div").id("customAttribute");
    String customAttribute = div.getText().replace("The custom value in the session is: ", "");
    // trigger reload
    findElement(By.id(WebpackDevServerPortView.TRIGGER_RELOAD_ID)).click();
    waitForElementPresent(By.id("customAttribute"));
    div = $("div").id("customAttribute");
    String customAttributeAfterReload = div.getText().replace("The custom value in the session is: ", "");
    Assert.assertEquals(customAttribute, customAttributeAfterReload);
    // trigger reload
    findElement(By.id(WebpackDevServerPortView.TRIGGER_RELOAD_ID)).click();
    waitForElementPresent(By.id("customAttribute"));
    div = $("div").id("customAttribute");
    String customAttributeAfterSecondReload = div.getText().replace("The custom value in the session is: ", "");
    Assert.assertEquals(customAttribute, customAttributeAfterSecondReload);
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 4 with TestBenchElement

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

the class NoThemeComponentIT method themeIsNotApplied.

@Test
public void themeIsNotApplied() {
    open();
    TestBenchElement link = $("a").first();
    String text = link.getText();
    Assert.assertEquals("Hello notheme", text);
    String color = link.getCssValue("color");
    Assert.assertEquals("Unexpected color for a link. " + "@NoTheme should not theme a link anyhow.", "rgba(0, 0, 0, 1)", color);
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 5 with TestBenchElement

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

the class SecurityIT method assertAdminPageShown.

private void assertAdminPageShown(String fullName) {
    assertPathShown("admin");
    TestBenchElement welcome = waitUntil(driver -> $("*").id("welcome"));
    String welcomeText = welcome.getText();
    Assert.assertEquals("Welcome to the admin page, " + fullName, welcomeText);
}
Also used : TestBenchElement(com.vaadin.testbench.TestBenchElement)

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