Class UploadButtonLocator
- All Implemented Interfaces:
Clickable<UploadButton>,HasAriaLabelFilter<UploadButton,,UploadButtonLocator> HasTextFilter<UploadButton,,UploadButtonLocator> HasThemeFilter<UploadButton,UploadButtonLocator>
UploadButton, derived from
UploadButtonTester. Filter steps are inherited from
Locator; action methods delegate to a fresh tester
around the resolved component, so behavioral changes belong on the
tester, not here.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures the component is in a usable state before interaction.voidChecks that the last upload through theUploadManagerthe button is linked to delivered every one of its files, and fails otherwise.voidChecks that at least one file of the last upload through theUploadManagerthe button is linked to failed or was rejected, and fails otherwise.Gets the component being tested.Returns what happened to each file the user last selected, dropped or started through theUploadManagerthe button is linked to, in the order the files were given.voidSimulates the user picking the given file in the file dialog.voidSimulates the user picking a file with the given name, content type and contents in the file dialog.voiduploadAborted(File file) Simulates the user picking the given file in the file dialog and then aborting its upload.voiduploadAborted(String fileName, String contentType) Simulates the user picking a file with the given name and content type in the file dialog and then aborting its upload.voidSimulates the user picking several files at once in the file dialog.voiduploadAll(Collection<File> files) Simulates the user picking several files at once in the file dialog.voiduploadFailed(File file) Simulates the user picking the given file in the file dialog and its upload then failing.voiduploadFailed(String fileName, String contentType) Simulates the user picking a file with the given name and content type in the file dialog and its upload then failing.Methods inherited from class com.vaadin.browserless.locator.Locator
atIndex, component, components, exists, inside, inside, invalidate, self, with, withAttribute, withAttribute, withClassName, withCondition, withCondition, withId, withinSlot, withoutAttribute, withoutAttribute, withoutClassName, withTestIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.browserless.Clickable
click, click, click, middleClick, middleClick, rightClick, rightClickMethods inherited from interface com.vaadin.browserless.locator.HasAriaLabelFilter
withAriaLabel, withAriaLabelContainingMethods inherited from interface com.vaadin.browserless.locator.HasTextFilter
withText, withTextContainingMethods inherited from interface com.vaadin.browserless.locator.HasThemeFilter
withoutTheme, withoutTheme, withTheme, withTheme
-
Constructor Details
-
UploadButtonLocator
public UploadButtonLocator() -
UploadButtonLocator
-
-
Method Details
-
getComponent
Description copied from interface:ClickableGets the component being tested.- Specified by:
getComponentin interfaceClickable<UploadButton>- Returns:
- the component under test
-
ensureComponentIsUsable
public void ensureComponentIsUsable()Description copied from interface:ClickableEnsures the component is in a usable state before interaction.- Specified by:
ensureComponentIsUsablein interfaceClickable<UploadButton>
-
upload
Simulates the user picking the given file in the file dialog.The content type is detected from the file name. Javadoc copied from
UploadButtonTester.upload(java.io.File).- Parameters:
file- the file to upload
-
upload
Simulates the user picking a file with the given name, content type and contents in the file dialog. Javadoc copied fromUploadButtonTester.upload(java.lang.String,java.lang.String,byte[]).- Parameters:
fileName- name of the file to uploadcontentType- content type of the file to uploadcontents- file contents as an array of bytes
-
uploadAll
Simulates the user picking several files at once in the file dialog.The content types are detected from the file names. Javadoc copied from
UploadButtonTester.uploadAll(java.io.File[]).- Parameters:
files- the files to upload
-
uploadAll
Simulates the user picking several files at once in the file dialog.The content types are detected from the file names. Javadoc copied from
UploadButtonTester.uploadAll(java.util.Collection).- Parameters:
files- the files to upload
-
uploadAborted
Simulates the user picking the given file in the file dialog and then aborting its upload.As in the browser, the aborted file is dropped from the file list and a
UploadManager.FileRemovedEventis fired, freeing a slot whenUploadManager.setMaxFiles(int)is in use.The file is added and its transfer started in one go, whether or not
auto uploadis turned off. The content type is detected from the file name, and the file is not read. Javadoc copied fromUploadButtonTester.uploadAborted(java.io.File).- Parameters:
file- the file to upload- Throws:
IllegalStateException- if the component is not usable
-
uploadAborted
Simulates the user picking a file with the given name and content type in the file dialog and then aborting its upload.As in the browser, the aborted file is dropped from the file list and a
UploadManager.FileRemovedEventis fired, freeing a slot whenUploadManager.setMaxFiles(int)is in use.The file is added and its transfer started in one go, whether or not
auto uploadis turned off. Javadoc copied fromUploadButtonTester.uploadAborted(java.lang.String,java.lang.String).- Parameters:
fileName- name of the file to uploadcontentType- content type of the file to upload- Throws:
IllegalStateException- if the component is not usable
-
uploadFailed
Simulates the user picking the given file in the file dialog and its upload then failing.As in the browser, a file whose upload failed stays in the file list.
The file is added and its transfer started in one go, whether or not
auto uploadis turned off. The content type is detected from the file name, and the file is not read. Javadoc copied fromUploadButtonTester.uploadFailed(java.io.File).- Parameters:
file- the file to upload- Throws:
IllegalStateException- if the component is not usable
-
uploadFailed
Simulates the user picking a file with the given name and content type in the file dialog and its upload then failing.As in the browser, a file whose upload failed stays in the file list.
The file is added and its transfer started in one go, whether or not
auto uploadis turned off. Javadoc copied fromUploadButtonTester.uploadFailed(java.lang.String,java.lang.String).- Parameters:
fileName- name of the file to uploadcontentType- content type of the file to upload- Throws:
IllegalStateException- if the component is not usable
-
getLastUploadStatus
Returns what happened to each file the user last selected, dropped or started through theUploadManagerthe button is linked to, in the order the files were given.Files are reported as
UploadTester.UploadStatus.UPLOADEDonce the upload handler has consumed them, asUploadTester.UploadStatus.REJECTEDwhen the manager or Flow's server-side accepted type validation refused them, asUploadTester.UploadStatus.FAILEDwhen the handler threw, and asUploadTester.UploadStatus.PENDINGwhile they wait in the file list for auto upload being turned off. The error message of a file the manager refused is the client-side error code:tooManyFiles,fileIsTooBigorincorrectFileType. Javadoc copied fromUploadButtonTester.getLastUploadStatus().- Returns:
- the outcome of the last upload, one entry per file, or an empty list if nothing has been uploaded yet or the button is not linked to a manager
-
ensureUploaded
public void ensureUploaded()Checks that the last upload through theUploadManagerthe button is linked to delivered every one of its files, and fails otherwise. Javadoc copied fromUploadButtonTester.ensureUploaded().- Throws:
IllegalStateException- if no upload has been simulated, or if any file of the last upload was not uploaded- See Also:
-
ensureUploadFailed
public void ensureUploadFailed()Checks that at least one file of the last upload through theUploadManagerthe button is linked to failed or was rejected, and fails otherwise.Counterpart of
ensureUploaded()for a test about the failure case, such as an upload handler that throws or a file the manager refuses. UsegetLastUploadStatus()to check which file failed and why.A file left
UploadTester.UploadStatus.PENDINGdoes not count as failed: it was neither delivered nor refused, such as a file waiting because auto upload is turned off. Javadoc copied fromUploadButtonTester.ensureUploadFailed().- Throws:
IllegalStateException- if no upload has been simulated, or if no file of the last upload failed or was rejected- See Also:
-