Notifications and Selenium

Hello!

I have a test scenario, in which

a) the user enters a wrong value,
b) presses a button and
c) an error message (
notification
) appears.

I want to automate this test, including checking that the error message actually appears.

Is there any way to do it with plain Selenium?

When I right-click the notification (to select some check from the context menu), it disappears.

Thanks in advance

Dmitri

Hi Dmitri,

what if you change the type of notification to ERROR - AFAIR, it closes only when clicking to “X” icon not to entire notification area.

Hello!

Unfortunately, it doesn’t work that way - if I right-click the notification (with Notification.TYPE_ERROR_MESSAGE type) the window disappears.

At least on Windows 7 under Firefox 3.6.13.

Best regards

Dmitri

Hello!

I have another question - does
Vaadin TestBench
support testing notifications?

Thanks in advance

Dmitri

Hi Dmitri,

Vaadin TestBench does support recording of any notifications and asserting text in error type notifications.

You will have to add text asserts by hand in the TestBench (Selenium) IDE, and select the notification element containing the text you want to assert. After this you will need to move the assert to before the recorded closeNotification event. Other than that inconvenience, it should work as expected.

HTH,
/Jonatan

is there a way to test Vaadin notifications in regular unit tests?

Hey,

Is there any way to handle notification using Testbench(selenium)webdriver code.

Using TestBench 4 you can find and interact with notifications like any other component, e.g.

NotificationElement notification = $(NotificationElement.class).first();
Assert.assertEquals("Hello world", notification.getDescription());
notification.close();