Class UploadManagerTester

java.lang.Object
com.vaadin.flow.component.upload.testbench.UploadManagerTester

public class UploadManagerTester extends Object
A test helper class for interacting with the client-side UploadManager. This class provides access to the upload manager's state and methods through any element that is linked to the manager.

Obtain an instance through UploadButtonElement.getUploadManager(), UploadDropZoneElement.getUploadManager(), or UploadFileListElement.getUploadManager().

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Aborts all uploads currently in progress.
    int
    Gets the number of files currently in the upload list.
    double
    Gets the maximum number of files that can be uploaded.
    boolean
    Checks whether the maximum number of files has been reached.
    void
    removeFile(int index)
    Removes the file at the given index.
    void
    upload(File file)
    Uploads the given local file.
    void
    upload(File file, int maxSeconds)
    Uploads the given local file and waits for the given number of seconds for the upload to finish.
    void
    Starts uploading all pending files.
    void
    uploadMultiple(List<File> files, int maxSeconds)
    Uploads the given local files and waits for the given number of seconds for all uploads to finish.
    void
    waitForUploads(int maxSeconds)
    Waits for all uploads to complete.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getMaxFiles

      public double getMaxFiles()
      Gets the maximum number of files that can be uploaded.
      Returns:
      the maximum number of files, or Infinity if unlimited
    • isMaxFilesReached

      public boolean isMaxFilesReached()
      Checks whether the maximum number of files has been reached.
      Returns:
      true if no more files can be uploaded, false otherwise
    • getFileCount

      public int getFileCount()
      Gets the number of files currently in the upload list.
      Returns:
      the number of files
    • removeFile

      public void removeFile(int index)
      Removes the file at the given index.
      Parameters:
      index - the index of the file to remove
    • uploadFiles

      public void uploadFiles()
      Starts uploading all pending files. This is useful when auto-upload is disabled.
    • abort

      public void abort()
      Aborts all uploads currently in progress.
    • waitForUploads

      public void waitForUploads(int maxSeconds)
      Waits for all uploads to complete.
      Parameters:
      maxSeconds - the maximum number of seconds to wait
    • upload

      public void upload(File file)
      Uploads the given local file. Waits for 60 seconds for the upload to finish.

      Note that Safari webdriver does not support file uploads.

      Parameters:
      file - a reference to the local file to upload
    • upload

      public void upload(File file, int maxSeconds)
      Uploads the given local file and waits for the given number of seconds for the upload to finish.

      Note that Safari webdriver does not support file uploads.

      Parameters:
      file - the local file to upload
      maxSeconds - the number of seconds to wait for the upload to finish or 0 not to wait
    • uploadMultiple

      public void uploadMultiple(List<File> files, int maxSeconds)
      Uploads the given local files and waits for the given number of seconds for all uploads to finish.

      Note that Safari webdriver does not support file uploads.

      Parameters:
      files - the local files to upload
      maxSeconds - the number of seconds to wait for uploads to finish or 0 not to wait