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.
Locator
required
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.String
required
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.String
required
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.Path...
required
File paths to upload (varargs)
removeFile(String fileName)
Remove a file from the list using the remove button.String
required
The file name to remove
Assertion Methods
assertHasFile(String fileName)
Assert that a file is listed in the upload file list.String
required
The expected file name
assertNoFile(String fileName)
Assert that a file is not present in the upload file list.String
required
The file name that should be absent
assertFileComplete(String fileName)
Assert that a file row is marked complete.String
required
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.
Page
required
The Playwright page instance
String
required
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