Overview
UploadElement is a Playwright wrapper for <vaadin-upload>. It provides helpers to feed files via the native file input, inspect the file list entries, and assert upload completion using the file row state.
Component tag: vaadin-upload
Implements:
HasEnabledElementHasValidationPropertiesElementHasThemeElementFocusableElement
Constructors
UploadElement(Locator locator)
Create a newUploadElement from an existing locator.
The Playwright locator for the
<vaadin-upload> elementInternal Locator Methods
getFileInputLocator()
Get the locator for the nativeinput[type=file] element.
Returns: Locator - The file input locator
getUploadButtonLocator()
Get the locator for the primary upload button. Returns:Locator - The upload button locator
getFileItemLocator(String fileName)
Get the locator for a specific file row.The file name to search for
Locator - The matching file row locator (<vaadin-upload-file>)
getFileStatusLocator(String fileName)
Get the locator for the status cell of a given file row.The file name to search for
Locator - The matching status locator
Action Methods
uploadFiles(Path… files)
Upload one or more files by feeding the hidden input.File paths to upload (varargs)
removeFile(String fileName)
Remove a file from the list using the remove button.The file name to remove
Assertion Methods
assertHasFile(String fileName)
Assert that a file is listed in the upload file list.The expected file name
assertNoFile(String fileName)
Assert that a file is not present in the upload file list.The file name that should be absent
assertFileComplete(String fileName)
Assert that a file row is marked complete.The file name to check
complete attribute.
assertMaxFilesReached()
Assert that the maximum number of files has been reached. Verifies: The upload element has themax-files-reached attribute.
Interface Overrides
getFocusLocator()
Get the locator for focus operations (targets the upload button). Returns:Locator - The upload button locator
getEnabledLocator()
Get the locator for enabled/disabled state checks (targets the upload button). Returns:Locator - The upload button locator
Static Factory Methods
getByButtonText(Page page, String buttonText)
Get theUploadElement by the accessible text of its upload button.
The Playwright page instance
The accessible text of the upload button (uses ARIA role BUTTON)
UploadElement - The matching upload element
Usage Example
Notes
- File upload uses the native
input[type=file]element viasetInputFiles() - File rows are represented as
<vaadin-upload-file>elements - The
completeattribute indicates successful upload - Factory lookup uses the upload button’s accessible name with ARIA role
button - Multiple files can be uploaded at once by passing multiple paths
- Focus and enabled/disabled operations target the upload button