Class TestBenchCommandExecutor

java.lang.Object
com.vaadin.testbench.commands.TestBenchCommandExecutor
All Implemented Interfaces:
CanCompareScreenshots, TestBenchCommands, HasDriver

public class TestBenchCommandExecutor extends Object implements TestBenchCommands, HasDriver
Provides actual implementation of TestBenchCommands
  • Constructor Details

  • Method Details

    • setDriver

      public void setDriver(TestBenchDriverProxy driver)
    • getRemoteControlName

      public String getRemoteControlName()
      Description copied from interface: TestBenchCommands
      Finds the canonical host name of the remotely executing node where the test is being run. This is useful for failure reporting when running on large grids where one machine may start having problems and you need to find out which of the machines it is.
      Specified by:
      getRemoteControlName in interface TestBenchCommands
      Returns:
      the canonical host name along with it's IP as a string.
    • waitForVaadin

      public void waitForVaadin()
      Block until Vaadin reports it has finished processing server messages.
    • compareScreen

      public boolean compareScreen(String referenceId) throws IOException
      Description copied from interface: CanCompareScreenshots
      Tests that a screen shot is equal to the specified reference image. The comparison tolerance can be specified by setting the com.vaadin.testbench.block.error system property to a value between 0 and 1, where 0 == no changes are accepted and 1 == big changes are accepted. Note that specifying 1 doesn't mean that any reference image is accepted.
      Specified by:
      compareScreen in interface CanCompareScreenshots
      Parameters:
      referenceId - the ID of the reference image
      Returns:
      true if the screenshot is considered equal to the reference image, false otherwise.
      Throws:
      IOException - if there was a problem accessing the reference image
    • compareScreen

      public boolean compareScreen(File reference) throws IOException
      Description copied from interface: CanCompareScreenshots
      Tests that a screen shot is equal to the specified reference image. The comparison tolerance can be specified by setting the com.vaadin.testbench.block.error system property to a value between 0 and 1, where 0 == no changes are accepted and 1 == all changes are accepted.
      Specified by:
      compareScreen in interface CanCompareScreenshots
      Parameters:
      reference - the reference image file
      Returns:
      true if the screenshot is considered equal to the reference image, false otherwise.
      Throws:
      IOException - if there was a problem accessing the reference image
    • compareScreen

      public boolean compareScreen(BufferedImage reference, String referenceName) throws IOException
      Description copied from interface: CanCompareScreenshots
      Tests that a screen shot is equal to the specified reference image. The comparison tolerance can be specified by setting the com.vaadin.testbench.block.error system property to a value between 0 and 1, where 0 == no changes are accepted and 1 == all changes are accepted.
      Specified by:
      compareScreen in interface CanCompareScreenshots
      Parameters:
      reference - the reference image
      referenceName - the filename of the reference image. Used when writing the error files.
      Returns:
      true if the screenshot is considered equal to the reference image, false otherwise.
      Throws:
      IOException - if there was a problem accessing the reference image
    • timeSpentRenderingLastRequest

      public long timeSpentRenderingLastRequest()
      Description copied from interface: TestBenchCommands
      This method provides performance information of the client-side rendering for the last operation performed. You can use this information to make sure that some operation is executed in a timely fashion. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications. Note! This method needs to be called before TestBenchCommands.timeSpentRenderingLastRequest() or TestBenchCommands.totalTimeSpentServicingRequests(), since they will perform an extra request, causing the value returned from this method to be that for an empty request/response.
      Specified by:
      timeSpentRenderingLastRequest in interface TestBenchCommands
      Returns:
      the time spent rendering the last request.
    • totalTimeSpentRendering

      public long totalTimeSpentRendering()
      Description copied from interface: TestBenchCommands
      This method provides performance information of the client-side rendering for the entire session. The session starts when you navigate to an application and this method returns the amount of time spent rendering up to the point of the call. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications.
      Specified by:
      totalTimeSpentRendering in interface TestBenchCommands
      Returns:
      the total time spent rendering in this session.
    • timeSpentServicingLastRequest

      public long timeSpentServicingLastRequest()
      Description copied from interface: TestBenchCommands
      This method provides performance information of the server-side processing for the last request. You can use this information to ensure that an operation is processed in a timely fashion. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications. Note! If you are interested in the client-side performance for the last request, you must call TestBenchCommands.timeSpentRenderingLastRequest() before calling this method. This is due to the fact that this method causes an extra server round-trip, which will cause an empty response to be rendered.
      Specified by:
      timeSpentServicingLastRequest in interface TestBenchCommands
      Returns:
      the time spent servicing the last request on the server.
    • totalTimeSpentServicingRequests

      public long totalTimeSpentServicingRequests()
      Description copied from interface: TestBenchCommands
      This method provides performance information of the server-side processing for the entire session. The session starts when you navigate to an application and this method returns the amount of time spent processing requests up to the point of the call. If more than one application is running at the same URL, e.g. a portal environment with many portlets on the same page, the value returned will be the sum for all applications. Note! If you are interested in the client-side performance for the last request, you must call TestBenchCommands.timeSpentRenderingLastRequest() before calling this method. This is due to the fact that this method causes an extra server round-trip, which will cause an empty response to be rendered.
      Specified by:
      totalTimeSpentServicingRequests in interface TestBenchCommands
      Returns:
      the total time spent servicing requests in this session.
    • disableWaitForVaadin

      public void disableWaitForVaadin()
      Description copied from interface: TestBenchCommands
      Disables implicit waiting for Vaadin to finish processing requests. This is useful if you need to test bombarding an application with events. Implicit waiting is enabled by default.
      Specified by:
      disableWaitForVaadin in interface TestBenchCommands
    • enableWaitForVaadin

      public void enableWaitForVaadin()
      Description copied from interface: TestBenchCommands
      Enables implicit waiting for Vaadin to finish processing requests. Implicit waiting is enabled by default.
      Specified by:
      enableWaitForVaadin in interface TestBenchCommands
    • isAutoScrollIntoView

      public boolean isAutoScrollIntoView()
      Whether or not the elements should be scrolled into the visible area of the browser window before interacting with them. The default is true
      Specified by:
      isAutoScrollIntoView in interface TestBenchCommands
      Returns:
      true if elements should be scrolled, otherwise false
    • setAutoScrollIntoView

      public void setAutoScrollIntoView(boolean autoScrollIntoView)
      Sets if the elements should be scrolled into the visible area of the browser window before interacting with them
      Specified by:
      setAutoScrollIntoView in interface TestBenchCommands
      Parameters:
      autoScrollIntoView - true if elements should be scrolled
    • executeScript

      public Object executeScript(String script, Object... args)
    • executeAsyncScript

      protected Object executeAsyncScript(String script, Object... args)
    • getDriver

      public TestBenchDriverProxy getDriver()
      Return a reference to the WebDriver instance associated with this TestBenchCommandExecutor
      Specified by:
      getDriver in interface HasDriver
      Returns:
      a WebDriver instance
    • resizeViewPortTo

      public void resizeViewPortTo(int desiredWidth, int desiredHeight) throws UnsupportedOperationException
      Description copied from interface: TestBenchCommands
      Tries to resize the browsers window so that the space available for actual web content (aka viewport) is of given size.

      Note, that the result cannot be guaranteed on all platforms. For example browsers in mobile devices are most often always fullscreen and their viewport can be "simultated". Also browsers might not allow resizing the window or limit size of window to minimum or maximum (often limited by screen size). Currently most common desktop browsers support this.

      Specified by:
      resizeViewPortTo in interface TestBenchCommands
      Parameters:
      desiredWidth - the desired width of the viewport
      desiredHeight - the desired height of the viewport
      Throws:
      UnsupportedOperationException
    • focusElement

      public void focusElement(TestBenchElement testBenchElement)
    • getReferenceNameGenerator

      public ReferenceNameGenerator getReferenceNameGenerator()
      Gets the name generator used for screenshot references.
      Returns:
      the name generator for screenshot references
    • getImageComparison

      public ImageComparison getImageComparison()
      Gets the image comparison implementation used for screenshots.
      Returns:
      the image comparison implementation