Class UploadElement

  • All Implemented Interfaces:
    com.vaadin.testbench.commands.CanCompareScreenshots, com.vaadin.testbench.HasCallFunction, com.vaadin.testbench.HasDriver, com.vaadin.testbench.HasElementQuery, com.vaadin.testbench.HasPropertySettersGetters, com.vaadin.testbench.HasSearchContext, com.vaadin.testbench.HasTestBenchCommandExecutor, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebElement, org.openqa.selenium.WrapsElement

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

      Constructors 
      Constructor Description
      UploadElement()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()
      Aborts any upload currently in progress.
      int getMaxFiles()
      Gets how many files can be uploaded.
      boolean isMaxFilesReached()
      Checks whether the maximum number of files has been uploaded.
      void upload​(File file)
      Uploads the given local file and waits for 60s for the upload to finish.
      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 uploadMultiple​(List<File> files, int maxSeconds)
      Uploads the given local files and waits for the given number of seconds for the upload to finish.
      • Methods inherited from class com.vaadin.testbench.TestBenchElement

        callFunction, clear, click, click, compareScreen, compareScreen, compareScreen, contextClick, dispatchEvent, dispatchEvent, doubleClick, equals, executeScript, findElement, findElements, focus, getAttribute, getCapabilities, getChildren, getClassNames, getCommandExecutor, getContext, getCssValue, getDriver, getId, getLocation, getParent, getProperty, getPropertyBoolean, getPropertyDouble, getPropertyElement, getPropertyElements, getPropertyInteger, getPropertyString, getRect, getScreenshotAs, getShadowRoot, getSize, getTagName, getText, getWrappedElement, hasAttribute, hasClassName, hashCode, hover, init, init, isChrome, isDisplayed, isEnabled, isFirefox, isFocused, isReadOnly, isSelected, scroll, scrollIntoView, scrollLeft, sendKeys, setProperty, setProperty, setProperty, setProperty, submit, waitForVaadin, waitUntil, waitUntil, wrap, wrapElement, wrapElements
      • Methods inherited from interface com.vaadin.testbench.HasElementQuery

        $, $
      • Methods inherited from interface org.openqa.selenium.WebElement

        getAccessibleName, getAriaRole, getDomAttribute, getDomProperty
    • Constructor Detail

      • UploadElement

        public UploadElement()
    • Method Detail

      • 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.