Search in sources :

Example 1 with DivElement

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

the class TSIT method lumoBadgeIsRenderedCorrectly.

@Test
public void lumoBadgeIsRenderedCorrectly() {
    open();
    checkLogsForErrors();
    DivElement badge = $("ts-component").first().$(DivElement.class).attribute("theme", "badge").first();
    String badgeBackgroundColor = badge.getCssValue("backgroundColor");
    Assert.assertEquals("rgba(51, 139, 255, 0.13)", badgeBackgroundColor);
}
Also used : DivElement(com.vaadin.flow.component.html.testbench.DivElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 2 with DivElement

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

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

the class ShadowRootIT method checkShadowRoot.

@Test
public void checkShadowRoot() {
    open();
    DivElement div = $(DivElement.class).id("test-element");
    WebElement shadowDiv = div.$(DivElement.class).id("shadow-div");
    Assert.assertEquals("Div inside shadow DOM", shadowDiv.getText());
    WebElement shadowLabel = div.$(LabelElement.class).id("shadow-label");
    Assert.assertEquals("Label inside shadow DOM", shadowLabel.getText());
    findElement(By.id("remove")).click();
    Assert.assertTrue("Child has not been removed from the shadow root", findElements(By.id("shadow-label")).isEmpty());
}
Also used : DivElement(com.vaadin.flow.component.html.testbench.DivElement) LabelElement(com.vaadin.flow.component.html.testbench.LabelElement) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 4 with DivElement

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

the class ModelListIT method clickOnAddedItems_itemsAreUpdated.

@Test
public void clickOnAddedItems_itemsAreUpdated() {
    DivElement repeat1 = findRepeatByID("repeat-1");
    DivElement repeat2 = findRepeatByID("repeat-2");
    DivElement repeat3 = findRepeatByID("repeat-3");
    DivElement repeat4 = findRepeatByID("repeat-4");
    assertClickedStates();
    repeat1.findElements(By.tagName("div")).get(1).click();
    assertClickedStates(1);
    repeat2.findElements(By.tagName("div")).get(1).click();
    assertClickedStates(1, 3);
    repeat3.findElements(By.tagName("div")).get(1).click();
    assertClickedStates(1, 3, 5);
    repeat3.findElements(By.tagName("div")).get(3).click();
    assertClickedStates(1, 3, 5, 7);
    repeat4.findElements(By.tagName("div")).get(1).click();
    assertClickedStates(1, 3, 5, 7, 9);
}
Also used : DivElement(com.vaadin.flow.component.html.testbench.DivElement) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 5 with DivElement

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

the class ModelListIT method assertClickedStates.

private void assertClickedStates(int... clicked) {
    DivElement repeat1 = findRepeatByID("repeat-1");
    DivElement repeat2 = findRepeatByID("repeat-2");
    DivElement repeat3 = findRepeatByID("repeat-3");
    DivElement repeat4 = findRepeatByID("repeat-4");
    List<DivElement> divs = new ArrayList<>();
    divs.addAll(repeat1.$(DivElement.class).all());
    divs.addAll(repeat2.$(DivElement.class).all());
    divs.addAll(repeat3.$(DivElement.class).all());
    divs.addAll(repeat4.$(DivElement.class).all());
    divs.add(findRepeatByID("item-with-item-div"));
    for (int i = 0; i < divs.size(); i++) {
        int index = i;
        boolean clickedState = IntStream.of(clicked).anyMatch(x -> x == index);
        Assert.assertThat(divs.get(index).getText(), CoreMatchers.startsWith(String.valueOf(clickedState)));
    }
}
Also used : DivElement(com.vaadin.flow.component.html.testbench.DivElement) ArrayList(java.util.ArrayList)

Aggregations

DivElement (com.vaadin.flow.component.html.testbench.DivElement)12 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)11 Test (org.junit.Test)11 NativeButtonElement (com.vaadin.flow.component.html.testbench.NativeButtonElement)2 WebElement (org.openqa.selenium.WebElement)2 LabelElement (com.vaadin.flow.component.html.testbench.LabelElement)1 ArrayList (java.util.ArrayList)1