Class UploadElement

java.lang.Object
com.vaadin.testbench.TestBenchElement
com.vaadin.flow.component.upload.testbench.UploadElement
All Implemented Interfaces:
CanCompareScreenshots, HasCallFunction, HasDriver, HasElementQuery, HasPropertySettersGetters, HasSearchContext, HasTestBenchCommandExecutor, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebElement, org.openqa.selenium.WrapsElement

public class UploadElement extends TestBenchElement
A TestBench element representing a <vaadin-upload> element.
  • Constructor Details

    • UploadElement

      public UploadElement()
  • Method Details

    • upload

      public void upload(File file)
      Uploads the given local file and waits for 60s 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 the upload to finish.

      Note that Safari webdriver does not support file uploads.

      Technically this temporarily disables the auto-upload feature, schedules all files for upload, and then starts the upload manually. This is necessary, because when running tests locally, uploads can finish even before we can schedule the command through the Selenium API.

      Parameters:
      files - the local files to upload, can reference the same file multiple times
      maxSeconds - the number of seconds to wait for the upload to finish or 0 not to wait
    • getMaxFiles

      public int getMaxFiles()
      Gets how many files can be uploaded.
      Returns:
      the number of files which can be uploaded
    • isMaxFilesReached

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

      public void abort()
      Aborts any upload currently in progress.