You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CriticalNotificationsTest.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package com.vaadin.tests.application;
  2. import java.util.Arrays;
  3. import java.util.List;
  4. import org.junit.Test;
  5. import org.openqa.selenium.remote.DesiredCapabilities;
  6. import com.vaadin.testbench.elements.ButtonElement;
  7. import com.vaadin.testbench.elements.CheckBoxElement;
  8. import com.vaadin.testbench.elements.NotificationElement;
  9. import com.vaadin.testbench.parallel.Browser;
  10. import com.vaadin.tests.tb3.MultiBrowserThemeTest;
  11. public class CriticalNotificationsTest extends MultiBrowserThemeTest {
  12. @Override
  13. public List<DesiredCapabilities> getBrowsersToTest() {
  14. return Arrays.asList(Browser.CHROME.getDesiredCapabilities(),
  15. Browser.FIREFOX.getDesiredCapabilities());
  16. }
  17. @Test
  18. public void internalError() throws Exception {
  19. testCriticalNotification("Internal error");
  20. }
  21. @Test
  22. public void internalErrorDetails() throws Exception {
  23. testCriticalNotification("Internal error", true);
  24. }
  25. @Test
  26. public void custom() throws Exception {
  27. testCriticalNotification("Custom");
  28. }
  29. @Test
  30. public void sessionExpired() throws Exception {
  31. testCriticalNotification("Session expired");
  32. }
  33. @Test
  34. public void sessionExpiredDetails() throws Exception {
  35. testCriticalNotification("Session expired", true);
  36. }
  37. private void testCriticalNotification(String buttonCaption)
  38. throws Exception {
  39. testCriticalNotification(buttonCaption, false);
  40. }
  41. private void testCriticalNotification(String buttonCaption,
  42. boolean withDetails) throws Exception {
  43. openTestURL(); // "theme=" + getTheme());
  44. if (withDetails) {
  45. click($(CheckBoxElement.class).caption("Include details").first());
  46. }
  47. $(ButtonElement.class).caption(buttonCaption).first().click();
  48. // some critical notifications invalidate the session, and if a
  49. // screenshot does not match, waitForVaadin would cause the screenshot
  50. // comparison to crash because of a missing session
  51. testBench().disableWaitForVaadin();
  52. // Give the notification some time to animate
  53. sleep(1000);
  54. compareScreen($(NotificationElement.class).first(),
  55. "systemnotification");
  56. }
  57. @Override
  58. protected Class<?> getUIClass() {
  59. return CriticalNotifications.class;
  60. }
  61. }