Class WaitForDownload
java.lang.Object
net.serenitybdd.screenplay.playwright.interactions.WaitForDownload
- All Implemented Interfaces:
net.serenitybdd.core.SkipNested,net.serenitybdd.screenplay.Performable
Wait for a file download while performing an action that triggers it.
Sample usage:
// Wait for download while clicking a link
actor.attemptsTo(
WaitForDownload.whilePerforming(Click.on("#download-btn"))
.andSaveAs("downloaded-file.pdf")
);
// Wait for download and save to specific path
actor.attemptsTo(
WaitForDownload.whilePerforming(Click.on(DOWNLOAD_LINK))
.andSaveTo(Paths.get("downloads/report.xlsx"))
);
// Just wait for download without saving
actor.attemptsTo(
WaitForDownload.whilePerforming(Click.on("#export-btn"))
);
After performing this interaction, you can use DownloadedFile
to query information about the most recent download.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionSave the downloaded file with the specified filename in the default downloads directory.Save the downloaded file to the specified path.static StringGet the key used to store the last download in actor's memory.<T extends net.serenitybdd.screenplay.Actor>
voidperformAs(T actor) static WaitForDownloadwhilePerforming(net.serenitybdd.screenplay.Performable action) Wait for a download while performing the specified action.withTimeout(double timeoutMs) Set a custom timeout for waiting for the download.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.serenitybdd.screenplay.Performable
then
-
Method Details
-
whilePerforming
Wait for a download while performing the specified action.- Parameters:
action- The action that triggers the download (e.g., clicking a download button)
-
andSaveAs
Save the downloaded file with the specified filename in the default downloads directory.- Parameters:
filename- The filename to save as
-
andSaveTo
Save the downloaded file to the specified path.- Parameters:
path- The full path where the file should be saved
-
withTimeout
Set a custom timeout for waiting for the download.- Parameters:
timeoutMs- Timeout in milliseconds
-
performAs
public <T extends net.serenitybdd.screenplay.Actor> void performAs(T actor) - Specified by:
performAsin interfacenet.serenitybdd.screenplay.Performable
-
getLastDownloadKey
Get the key used to store the last download in actor's memory.
-