Class UiTestUtils

java.lang.Object
io.jmix.flowui.testassist.UiTestUtils

public final class UiTestUtils extends Object
Class provides helper methods for testing.
  • Method Details

    • getCurrentView

      public static <T extends View<?>> T getCurrentView()
      Returns instance of currently navigated view. Usage example:
       @Test
       public void navigateToUserListView() {
           viewNavigators.view(UserListView.class)
                   .navigate();
      
           UserListView view = UiTestUtils.getCurrentView();
       }
       
      Type Parameters:
      T - type of navigated view
      Returns:
      instance of the currently navigated view
    • getComponent

      public static <T> T getComponent(View<?> view, String componentId)
      Returns a component defined in the view by the component id.
      Throws:
      IllegalArgumentException - if not found
    • validateView

      public static ValidationErrors validateView(StandardDetailView<?> view)
      Validates provided View by calling StandardDetailView#validateView() method from it.
      Parameters:
      view - detail view to validate
      Returns:
      errors if validation failed, otherwise empty object will be returned
    • getOpenedNotifications

      public static List<NotificationInfo> getOpenedNotifications()
      Returns an immutable list of NotificationInfo objects in the order they were opened.

      Example of the order in which notifications are stored:

      • first opened notification has index 0
      • second opened notification has index 1
      • last opened notification has index openedNotifications.size() - 1
      Returns:
      immutable list of NotificationInfo in order of opening
    • getLastOpenedNotification

      public static @Nullable NotificationInfo getLastOpenedNotification()
      Returns:
      the most recent opened NotificationInfo or null if no opened notifications
    • getOpenedDialogs

      public static List<DialogInfo> getOpenedDialogs()
      Returns an immutable list of DialogInfo objects in the order they were opened.

      This method covers component Dialogs created via Dialogs (message, option, background-task and side dialogs). Views shown as dialogs (e.g. InputDialog or any view opened in OpenMode.DIALOG) are not included here — use getOpenedViewDialogs().

      Example of the order in which dialogs are stored:

      • first opened dialog has index 0
      • second opened dialog has index 1
      • last opened dialog has index openedDialogs.size() - 1
      Returns:
      immutable list of DialogInfos in order of opening
    • getLastOpenedDialog

      public static @Nullable DialogInfo getLastOpenedDialog()
      Returns the most recently opened component Dialog created via Dialogs. For views shown as dialogs (e.g. InputDialog) use getLastOpenedViewDialog().
      Returns:
      the most recent opened DialogInfo or null if no opened dialogs
    • getOpenedViewDialogs

      public static List<View<?>> getOpenedViewDialogs()
      Returns an immutable list of Views shown as dialogs (i.e. opened in OpenMode.DIALOG), in the order they were opened. This includes any lookup or detail view opened as a dialog, as well as the framework InputDialog.

      Example of the order in which view dialogs are stored:

      • first opened view dialog has index 0
      • second opened view dialog has index 1
      • last opened view dialog has index openedViewDialogs.size() - 1

      For component dialogs created via Dialogs (message, option, background-task and side dialogs) use getOpenedDialogs() instead.

      Returns:
      immutable list of Views shown as dialogs, in order of opening
    • getLastOpenedViewDialog

      public static <T extends View<?>> @Nullable T getLastOpenedViewDialog()
      Returns the most recently opened View shown as a dialog, i.e. the topmost view opened in OpenMode.DIALOG (a lookup or detail view, a custom view, etc.). Usage example:
       // open a view as a dialog (e.g. via DialogWindows or OpenMode.DIALOG), then:
       CustomerDetailView view = UiTestUtils.getLastOpenedViewDialog();
       

      Note: the framework InputDialog is also a view dialog and can be obtained the same way.

      Type Parameters:
      T - expected type of the view
      Returns:
      the most recently opened view dialog, or null if there are no opened view dialogs