use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class WebComponentIT method indexPageGetsWebComponent_attributeIsReflectedToServer.
@Test
public void indexPageGetsWebComponent_attributeIsReflectedToServer() {
open();
waitForElementVisible(By.id("show-message"));
TestBenchElement showMessage = byId("show-message");
waitUntil(driver -> showMessage.$("select").exists());
TestBenchElement select = showMessage.$("select").first();
// Selection is visibly changed and event manually dispatched
// as else the change is not seen.
getCommandExecutor().executeScript("arguments[0].value='Peter';" + "arguments[0].dispatchEvent(new Event('change'));", select);
Assert.assertEquals("Selected: Peter, Parker", showMessage.$("span").first().getText());
TestBenchElement noMessage = byId("no-message");
select = noMessage.$("select").first();
getCommandExecutor().executeScript("arguments[0].value='Peter';" + "arguments[0].dispatchEvent(new Event('change'));", select);
Assert.assertFalse("Message should not be visible", noMessage.$("span").first().isDisplayed());
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class FeatureIT method toggleViteFeature.
private void toggleViteFeature(boolean expectedInitialState) {
DevModeGizmoElement gizmo = $(DevModeGizmoElement.class).waitForFirst();
gizmo.expand();
gizmo.$(NativeButtonElement.class).id("features").click();
TestBenchElement toggleButton = gizmo.$(TestBenchElement.class).id("feature-toggle-viteForFrontendBuild");
String checked = getCommandExecutor().executeScript("return arguments[0].checked", toggleButton).toString();
Assert.assertEquals("Toggle button state expected " + expectedInitialState, Boolean.toString(expectedInitialState), checked);
toggleButton.click();
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class EmbeddedWebComponentIT method servletPageGetsWebComponent_attributeIsReflectedToServer.
@Test
public void servletPageGetsWebComponent_attributeIsReflectedToServer() {
open();
// Check that there is no pwa install prompt
Assert.assertFalse(isElementPresent(By.id("pwa-ip")));
TestBenchElement webComponent = $("client-select").first();
Assert.assertTrue(webComponent.getText().trim().startsWith("Web Component"));
// Selection is visibly changed and event manually dispatched
// as else the change is not seen.
getCommandExecutor().executeScript("arguments[0].value='Peter';" + "arguments[0].dispatchEvent(new Event('change'));", webComponent.$("select").first());
TestBenchElement msg = webComponent.$("span").first();
Assert.assertEquals("Selected: Peter, Parker", msg.getText());
// Check that there is correctly imported custom element
TestBenchElement dependencyElement = webComponent.$("dep-element").first();
Assert.assertEquals("Imported element", byId(dependencyElement, "main").getText());
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class FireEventIT method customEventsGetSentToTheClientSide.
@Test
public void customEventsGetSentToTheClientSide() {
open();
waitForElementVisible(By.id("calc"));
TestBenchElement calc = byId("calc");
TestBenchElement button = byId("calc", "button");
TestBenchElement number1 = byId("calc", N1);
TestBenchElement number2 = byId("calc", N2);
Assert.assertEquals("Sum should be 0", "0", value(SUM));
Assert.assertEquals("Error should be empty", "", value(ERR));
number1.sendKeys("4.5", Keys.ENTER);
number2.sendKeys("3.5", Keys.ENTER);
button.click();
Assert.assertEquals("Sum should be 8", "8", value(SUM));
Assert.assertEquals("Error should be empty", "", value(ERR));
number1.clear();
number2.clear();
Assert.assertEquals("", value(number1));
Assert.assertEquals("", value(number2));
button.click();
Assert.assertEquals("Sum should not have changed", "8", value(SUM));
Assert.assertEquals("Error should have been raised", "empty String", value(ERR));
number1.sendKeys("99", Keys.ENTER);
number2.sendKeys("101", Keys.ENTER);
button.click();
Assert.assertEquals("Sum should be 200", "200", value(SUM));
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class NpmOnlyIndexIT method globalStylesAreUnderTheWebComponent.
// test for #7005
@Test
public void globalStylesAreUnderTheWebComponent() {
open();
waitForElementVisible(By.tagName("themed-web-component"));
TestBenchElement webComponent = $("themed-web-component").first();
List<TestBenchElement> styles = webComponent.$("style").all();
System.out.println(styles.size());
// getAttribute wouldn't work, so we are counting the elements
Assert.assertEquals(2, styles.size());
}
Aggregations