Skip to content

Add support for file downloads - #39

Closed
tylerhunt wants to merge 2 commits into
ftes:mainfrom
tylerhunt:file-downloads
Closed

tylerhunt wants to merge 2 commits into
ftes:mainfrom
tylerhunt:file-downloads

Conversation

@tylerhunt

Copy link
Copy Markdown

Add PlaywrightEx.Download and PlaywrightEx.DownloadWaiter to handle file downloads.

Example:

{:ok, download_ref} = Page.expect_download(page.guid, timeout: @timeout)
{:ok, _} = Frame.click(frame.guid, selector: Selector.link("Download"), timeout: @timeout)
{:ok, path} = Page.await_download(download_ref)

tylerhunt and others added 2 commits April 16, 2026 10:35
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ftes

ftes commented May 4, 2026

Copy link
Copy Markdown
Owner

I haven't followed up on this yet, because I'm still thinking about how best to represent 'pending' actions, such as an expected action, in PlaywrightEx.

In a way that maps well to pheonix_test_playwright.

Sorry for taking so long on this.

ftes added a commit that referenced this pull request Sep 15, 2026
Adds download listeners that can be armed before an action and awaited
afterward, with download metadata and file saving over local and
WebSocket connections.

Supersedes #39.

## Changes

- Add `Page.expect_download/2` and `Page.await_download/1`, with
optional predicates on download metadata.
- Use linked Tasks for one-shot event capture, with synchronous
registration, one deadline, and owner/connection lifecycle handling.
- Add `Download.from_event/2`, `save_as/3`, and `delete/2`. Saving
preserves the source artifact so other readers can use it.
- Stage artifact saves before replacing the destination, share one
timeout across stream reads, and clean up files and streams on failure.
- Handle expected connection failures at the process boundary and allow
unexpected errors to propagate.

## Compatibility

- **Breaking:** `:infinity` disables timeouts; `0` means no waiting.
Zero-timeout protocol commands fail without being sent, while frame
URL/load-state waits check recorded state once. Migration guidance is in
`CHANGELOG.md`.
- Fix `:infinity` handling in frame waits and keyboard actions. Keyboard
delays cannot extend a zero timeout.
- URL predicate exceptions now propagate instead of becoming ordinary
error results.

## Validation

- `mix check`: 209 tests passed, including formatting, Credo,
compilation, and Dialyzer checks. The full suite also passed with the
original failing CI seed (`87788`) and concurrency (`8`).
- `mix docs --warnings-as-errors` passed.
- GitHub Actions: build/lint and all 209 tests passed over both port and
WebSocket transports.
- Consumer compatibility: 6 phoenix_test_playwright download tests and
32 Fluffy download, URL, and assertion tests passed against the local
implementation.
@ftes

ftes commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Superseeded by #87

@ftes ftes closed this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants