Class Mopo

java.lang.Object
in.virit.mopo.Mopo

public class Mopo extends Object
General utilities for Playwright and Vaadin.
  • Constructor Details

    • Mopo

      public Mopo(com.microsoft.playwright.Page page)
      Constructs a new Mopo for given page
      Parameters:
      page - the page use by this Mopo instance
  • Method Details

    • waitForConnectionToSettle

      public static void waitForConnectionToSettle(com.microsoft.playwright.Page page)
      Waits until the client-server communication by Vaadin has settled.
      Parameters:
      page - the page on which Vaadin app is expected to be run
    • waitForConnectionToSettle

      public static void waitForConnectionToSettle(com.microsoft.playwright.Page page, int minWait)
      Waits until the client-server communication by Vaadin has settled.
      Parameters:
      page - the page on which Vaadin app is expected to be run
      minWait - the minimum wait time spent to watch if client-server communication starts
    • assertNoJsErrors

      @Deprecated public static void assertNoJsErrors(com.microsoft.playwright.Page page)
      Deprecated.
      this method depends on dev mode, consider using failOnClientSideErrors() ()} and trackClientSideErrors() that use browser console.
      Asserts that there are no JS errors in the dev console.
      Parameters:
      page - the page to be checked
    • trackClientSideErrors

      public void trackClientSideErrors()
      Starts monitoring browser console and errors and collects those for further inspection (e.g. with getClientSideErrors() or failOnClientSideErrors()).
    • getClientSideErrors

      public List<String> getClientSideErrors()
      Returns the list of console errors that have been logged since the trackClientSideErrors() was called.
      Returns:
      a list of console messages that are errors
    • waitForConnectionToSettle

      public void waitForConnectionToSettle()
      Waits until the client-server communication by Vaadin has settled.
    • assertNoJsErrors

      @Deprecated public void assertNoJsErrors()
      Deprecated.
      this method depends on dev mode, consider using failOnClientSideErrors() ()} and trackClientSideErrors() that use browser console.
      Asserts that there are no JS errors in the dev console.
    • getViewsReportedByDevMode

      public List<String> getViewsReportedByDevMode(com.microsoft.playwright.Browser browser, String rootUrl)
      Returns a list of routes/views(URLs) that Vaadin app in development mode contains.
      Parameters:
      browser - the browser instance
      rootUrl - relative URLs of the test server views that in development time lists
      Returns:
      a list of URLs pointing to known routes
    • driveIn

      public void driveIn(String selector, Runnable taskToRun)
      Executes given task in a temporarily visible UI part, like a dialog or form. The UI part is expected to be detached after the task (implicitly asserted).
      Parameters:
      selector - a selector to the UI part to be accessed or a part within it (like a "Save" button)
      taskToRun - the task that should be performed in the temporarily visible component (composition)
    • driveIn

      public void driveIn(com.microsoft.playwright.Locator locator, Runnable taskToRun)
      Executes given task in a temporarily visible UI part, like a dialog or form. The UI part is expected to be hidden after the task.
      Parameters:
      locator - a locator to the UI part or a part within it (like a "Save" button). This is used to verify that the component is shown before the given task is executed and hidden after the execution.
      taskToRun - the task that should be performed in the temporarily visible component (composition)
    • click

      public void click(com.microsoft.playwright.Locator locator)
      A shorthand to click the referenced locator and to waitForConnectionToSettle(). This is a helper you can for example use for "Save" button in your form, that asynchronously changes content already present in the UI. When using this instead of the raw Playwright click, you can assert the changed content right away without further magic.
      Parameters:
      locator - the locator to click
    • click

      public void click(String selector)
      A shorthand to click the referenced selector and to waitForConnectionToSettle(). This is a helper you can for example use for "Save" button in your form, that asynchronously changes content already present in the UI. When using this instead of the raw Playwright click, you can assert the changed content right away without further magic.
      Parameters:
      selector - the selector to click
    • failOnClientSideErrors

      public void failOnClientSideErrors()
      Asserts that there are no client-side errors in the console. Throws a RuntimeException if there are any errors.