use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class DomRepeatIT method checkThatIndicesAreCorrect.
@Test
public void checkThatIndicesAreCorrect() {
open();
TestBenchElement template = $(TestBenchElement.class).id("template");
for (int i = 0; i < DomRepeatView.NUMBER_OF_EMPLOYEES; i++) {
template.$(TestBenchElement.class).id(DomRepeatView.TR_ID_PREFIX + i).click();
String eventIndex = template.$(TestBenchElement.class).id(DomRepeatView.EVENT_INDEX_ID).getText();
String repeatIndex = template.$(TestBenchElement.class).id(DomRepeatView.REPEAT_INDEX_ID).getText();
Assert.assertEquals(eventIndex, repeatIndex);
Assert.assertEquals(i, Integer.parseInt(repeatIndex));
}
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class EventHandlerIT method handleEventOnServer.
@Test
public void handleEventOnServer() {
open();
TestBenchElement template = $(TestBenchElement.class).id("template");
template.$(TestBenchElement.class).id("handle").click();
Assert.assertTrue("Unable to find server event handler invocation confirmation. " + "Looks like 'click' event handler has not been invoked on the server side", isElementPresent(By.id("event-handler-result")));
template.$(TestBenchElement.class).id("send").click();
TestBenchElement container = $(TestBenchElement.class).id("event-data");
List<TestBenchElement> divs = container.$("div").all();
Assert.assertEquals("Unexpected 'button' event data in the received event handler parameter", "button: 0", divs.get(1).getText());
Assert.assertEquals("Unexpected 'type' event data in the received event handler parameter", "type: click", divs.get(2).getText());
Assert.assertEquals("Unexpected 'tag' event data in the received event handler parameter", "tag: button", divs.get(3).getText());
// Check event functionality for event with both client and server
// handler
template.$(TestBenchElement.class).id("overridden").click();
Assert.assertTrue("Unable to find server event handler invocation confirmation.", isElementPresent(By.id("overridden-event-handler-result")));
Assert.assertEquals("Received result wasn't updated by client!", "Overridden server event was invoked with result: ClientSide handler", findElement(By.id("overridden-event-handler-result")).getText());
// @ClientCallable return value
template.$("button").id("client").click();
Assert.assertEquals("Server-side message should be present", "Call from client, message: foo, true", $("div").id("client-call").getText());
Assert.assertEquals("Message from awaiting return value should be present", "FOO", template.$("span").id("status").getText());
template.$("button").id("clientError").click();
Assert.assertEquals("Message from awaiting exception should be present", "Error: Something went wrong. Check server-side logs for more information.", template.$("span").id("status").getText());
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class BeanInListingIT method beanInTwoWayBinding.
@Test
public void beanInTwoWayBinding() throws InterruptedException {
open();
TestBenchElement selected = $(TestBenchElement.class).id("template").$(TestBenchElement.class).id("selected");
assertSelectionValue("user-item", selected, "foo");
assertSelectionValue("user-item", selected, "bar");
assertSelectionValue("msg-item", selected, "baz");
assertSelectionValue("msg-item", selected, "msg");
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class ChildOrderIT method prependTextsFromServer_textsAreAddedBeforeExistingOnes.
@Test
public void prependTextsFromServer_textsAreAddedBeforeExistingOnes() {
TestBenchElement container = root.$(TestBenchElement.class).id("containerWithText");
assertNodeOrder(container, "Client text");
clickAndWaitForContainerToChange(container, "prependChildToContainer2");
assertNodeOrder(container, "Client text", "Server text 1");
clickAndWaitForContainerToChange(container, "prependChildToContainer2");
assertNodeOrder(container, "Client text", "Server text 2", "Server text 1");
clickAndWaitForContainerToChange(container, "addClientSideChildToContainer2");
assertNodeOrder(container, "Client text", "Server text 2", "Server text 1", "Client text");
clickAndWaitForContainerToChange(container, "prependChildToContainer2");
assertNodeOrder(container, "Client text", "Server text 3", "Server text 2", "Server text 1", "Client text");
clickAndWaitForContainerToChange(container, "removeChildFromContainer2");
assertNodeOrder(container, "Client text", "Server text 3", "Server text 2", "Client text");
clickAndWaitForContainerToChange(container, "removeChildFromContainer2");
assertNodeOrder(container, "Client text", "Server text 3", "Client text");
}
use of com.vaadin.testbench.TestBenchElement in project flow by vaadin.
the class ChildOrderIT method clickAndWaitForContainerToChange.
private void clickAndWaitForContainerToChange(WebElement container, String buttonToclick) {
String innertText = container.getAttribute("innerText");
TestBenchElement button = root.$(TestBenchElement.class).id(buttonToclick);
button.click();
waitUntilNot(driver -> container.getAttribute("innerText").equals(innertText));
}
Aggregations