New Feature: Config download behavior (#13309)#3232
Closed
Conversation
Add ability to configure download behavior on launch/connect and on creation of new browser contexts via BrowserContextOptions.DownloadBehavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The 1000ms timeout was too tight for Windows CI runners. Use 10s for the success case and keep 1s for the deny case (which expects timeout). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The download test fails on all Windows CI configurations. The Chrome version used (145.0.7632.77) may have a bug with Browser.setDownloadBehavior on Windows that was fixed in the upstream version (145.0.7632.117). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Temporary diagnostics to understand why the download test fails on Windows: - Listen for CDP download events - List files in download directory after click - Check default Downloads folder - Additional CDP session to enable download events Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Browser.setDownloadBehavior with browserContextId doesn't reliably apply to new pages on Windows. Re-send it through the page's CDP session after page creation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CreateCDPSessionAsync approach was causing flakiness on Windows due to timing issues. Sending directly through Connection without browserContextId is simpler and more reliable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… context The request type was missing from SystemTextJsonSerializationContext, causing the DownloadPolicy enum to not serialize correctly (e.g. "Allow" instead of "allow"). This was the root cause of Windows download test failures. Removed the workaround of re-sending download behavior on page creation since it's no longer needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On Windows, Chrome requires eventsEnabled=true for download behavior to be properly applied to new pages in a browser context. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On Windows, Browser.setDownloadBehavior with browserContextId alone doesn't reliably apply to newly created pages. Send it again through the page's existing Client session (no new CDP session overhead) with eventsEnabled=true and without browserContextId. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change BrowserSetDownloadBehaviorRequest.Behavior from DownloadPolicy enum to string, using ToValueString() to convert. This ensures the value is always serialized as lowercase "allow"/"deny" regardless of how System.Text.Json handles enum converters on object-typed params. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…avior Replicate exactly what was proven to work on Windows: create a new CDP session from the page and send Browser.setDownloadBehavior using an anonymous object (avoiding any potential serialization issues with typed request classes). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Log CDP response from setDownloadBehavior - Log download events (downloadWillBegin, downloadProgress) - List files in download dir after 3s delay - Check default Downloads folder - Log browser version - Send extra setDownloadBehavior through CDP session This will help understand why downloads fail on Windows CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On Windows, Browser.setDownloadBehavior with browserContextId alone does not reliably apply to new pages. Re-send through a CDP session created from the page (without browserContextId, with eventsEnabled) to ensure downloads work cross-platform. Remove diagnostic test code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CreateCDPSessionAsync call must happen AFTER CreatePageInContextAsync returns (page fully initialized), not inside it. Move the per-page download behavior setup from CdpBrowser.CreatePageInContextAsync to CdpBrowserContext.NewPageAsync to match the timing that works on Windows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use the page's existing Client session instead of creating a new CDP session. Send with an anonymous object to ensure correct serialization via the session. This avoids CreateCDPSessionAsync overhead and potential timing issues on Windows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On Windows, the page target is not fully ready immediately after creation. Add Task.Delay(100) before CreateCDPSessionAsync to allow pending async operations to complete. Also use TempDirectory helper in tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace typed BrowserSetDownloadBehaviorRequest with anonymous object to match upstream JavaScript behavior. Remove per-page download behavior workaround in NewPageAsync as context-level setup is sufficient. Clean up unused import in CdpBrowser.cs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements changes from puppeteer/puppeteer#13309
Closes #2828