Search in sources :

Example 1 with ButtonElement

use of com.vaadin.flow.component.button.testbench.ButtonElement in project flow by vaadin.

the class FusionFormIT method save_backend_loaded_empty_values_for_required_fields_no_runtime_errors.

@Test
public void save_backend_loaded_empty_values_for_required_fields_no_runtime_errors() {
    ButtonElement loadDataButton = $(ButtonElement.class).id("load-from-endpoint");
    loadDataButton.click();
    ButtonElement saveButton = $(ButtonElement.class).id("save");
    waitUntil(driver -> saveButton.isEnabled());
    saveButton.click();
    NotificationElement notification = $(NotificationElement.class).id("notification");
    Assert.assertNotNull(notification);
    waitUntil(driver -> notification.isOpen());
    Assert.assertTrue(notification.getText().contains("must not be empty"));
    Assert.assertFalse(notification.getText().contains("Expected string but received null"));
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 2 with ButtonElement

use of com.vaadin.flow.component.button.testbench.ButtonElement in project skeleton-starter-flow-spring by vaadin.

the class MainViewIT method testClickButtonShowsHelloAnonymousUserNotificationWhenUserNameIsEmpty.

@Test
public void testClickButtonShowsHelloAnonymousUserNotificationWhenUserNameIsEmpty() {
    ButtonElement button = $(ButtonElement.class).waitForFirst();
    button.click();
    $(NotificationElement.class).waitForFirst();
    Assert.assertTrue($(NotificationElement.class).exists());
    NotificationElement notification = $(NotificationElement.class).first();
    Assert.assertEquals("Hello anonymous user", notification.getText());
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) Test(org.junit.Test)

Example 3 with ButtonElement

use of com.vaadin.flow.component.button.testbench.ButtonElement in project skeleton-starter-flow-spring by vaadin.

the class MainViewIT method clickingButtonTwiceShowsTwoNotifications.

@Test
public void clickingButtonTwiceShowsTwoNotifications() {
    Assert.assertFalse($(NotificationElement.class).exists());
    ButtonElement button = $(ButtonElement.class).waitForFirst();
    button.click();
    button.click();
    $(NotificationElement.class).waitForFirst();
    Assert.assertEquals(2, $(NotificationElement.class).all().size());
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) Test(org.junit.Test)

Example 4 with ButtonElement

use of com.vaadin.flow.component.button.testbench.ButtonElement in project flow by vaadin.

the class FusionFormIT method save_empty_values_for_required_fields_no_runtime_errors.

@Test
public void save_empty_values_for_required_fields_no_runtime_errors() {
    ButtonElement saveButton = $(ButtonElement.class).id("save");
    saveButton.click();
    NotificationElement notification = $(NotificationElement.class).id("notification");
    Assert.assertNotNull(notification);
    waitUntil(driver -> notification.isOpen());
    Assert.assertTrue(notification.getText().contains("must not be empty"));
    Assert.assertFalse(notification.getText().contains("Expected string but received a undefined"));
}
Also used : NotificationElement(com.vaadin.flow.component.notification.testbench.NotificationElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Example 5 with ButtonElement

use of com.vaadin.flow.component.button.testbench.ButtonElement in project flow by vaadin.

the class SimpleIT method simplePage_withWhiteList_works.

@Test
public void simplePage_withWhiteList_works() {
    TestBenchElement viewElement = $("simple-view").first();
    ButtonElement button = viewElement.$(ButtonElement.class).id("button");
    button.click();
    TextFieldElement log = viewElement.$(TextFieldElement.class).id("log");
    Assert.assertEquals(SimpleView.CLICKED_MESSAGE, log.getValue());
}
Also used : TextFieldElement(com.vaadin.flow.component.textfield.testbench.TextFieldElement) ButtonElement(com.vaadin.flow.component.button.testbench.ButtonElement) TestBenchElement(com.vaadin.testbench.TestBenchElement) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Test(org.junit.Test)

Aggregations

ButtonElement (com.vaadin.flow.component.button.testbench.ButtonElement)6 Test (org.junit.Test)6 NotificationElement (com.vaadin.flow.component.notification.testbench.NotificationElement)4 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)3 TestBenchElement (com.vaadin.testbench.TestBenchElement)2 TextFieldElement (com.vaadin.flow.component.textfield.testbench.TextFieldElement)1 HasElementQuery (com.vaadin.testbench.HasElementQuery)1 WebDriver (org.openqa.selenium.WebDriver)1