Skip to content

feat: add SetUserAgentAsync options overload with platform support - #3382

Merged
kblok merged 2 commits into
masterfrom
feat/set-user-agent-platform
Mar 11, 2026
Merged

kblok merged 2 commits into
masterfrom
feat/set-user-agent-platform

Conversation

@kblok

@kblok kblok commented Mar 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Add new SetUserAgentOptions class with UserAgent, UserAgentMetadata, and Platform properties
  • Add SetUserAgentAsync(SetUserAgentOptions) overload to IPage, Page, CdpPage, and BidiPage
  • Add Platform property to CDP NetworkSetUserAgentOverrideRequest and pass it through the NetworkManager

Details

Aligns with upstream Puppeteer's options-based setUserAgent overload. The existing SetUserAgentAsync(string, UserAgentMetadata) method remains unchanged for backward compatibility.

For CDP: when UserAgent is null in the options, falls back to the browser's default user agent via Browser.GetUserAgentAsync().

For BiDi: accepts the Platform parameter but does not use it yet (upstream uses client hints override which BiDi doesn't fully support).

Test plan

  • dotnet build PuppeteerSharp.csproj passes with 0 errors, 0 warnings
  • Verify existing SetUserAgentAsync tests still pass (backward compatible)

🤖 Generated with Claude Code

kblok and others added 2 commits March 11, 2026 09:27
Add SetUserAgentOptions class and a new SetUserAgentAsync(SetUserAgentOptions)
overload to IPage, Page, CdpPage, and BidiPage. The CDP NetworkManager now
supports an optional platform parameter passed through to
Network.setUserAgentOverride. When using the options overload on CDP, a null
UserAgent falls back to the browser's default user agent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kblok
kblok merged commit 15f1807 into master Mar 11, 2026
14 checks passed
@kblok
kblok deleted the feat/set-user-agent-platform branch March 11, 2026 15:19
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.

1 participant