Skip to content

Pluggable browser providers - #385

Merged
elacuesta merged 7 commits into
mainfrom
pluggable-browser-providers
Jul 10, 2026
Merged

elacuesta merged 7 commits into
mainfrom
pluggable-browser-providers

Conversation

@elacuesta

Copy link
Copy Markdown
Member

Strategy pattern implementation to allow integration of compatible third-party projects without having to touch the handler internals. Adds a PLAYWRIGHT_BROWSER_PROVIDER setting and a provider module with the default implementation (PlaywrightBrowserProvider).

Related to #326 and #345, closes #384,

@elacuesta
elacuesta requested review from Gallaecio, kmike and wRAR July 2, 2026 23:55
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5d5932d) to head (3d6c498).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #385   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         8    +1     
  Lines          710       735   +25     
=========================================
+ Hits           710       735   +25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread docs/pluggable-browser-providers.md Outdated
## The `BrowserProvider` interface

A provider is a class that accepts a configuration object in its constructor and
implements the following asynchronous lifecycle. You can subclass

@AdrianAtZyte AdrianAtZyte Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think protocol classes are not meant to be subclassed. And I was wrong. Subclassing is OK, and even recommended by some.

Comment thread docs/pluggable-browser-providers.md Outdated
```python
# settings
PLAYWRIGHT_BROWSER_PROVIDER = "myproject.providers.PatchrightBrowserProvider"
PLAYWRIGHT_BROWSER_TYPE = "chromium"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could make it so that a provider can make this setting unnecessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, unfortunately. Browser instances expose this via browser.browser_type.name, but persistent contexts do not have a linked browser type. The browser name is used internally in the handler, and there wouldn't be a way to retrieve it in persistent contexts.
An alternative would be to require browser providers to declare a browser name attribute, but that would be basically the same as the current setting.

@AdrianAtZyte AdrianAtZyte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Co-authored-by: Adrian <adrian@zyte.com>
@AdrianAtZyte

Copy link
Copy Markdown
Contributor

About 145360d, mind that the same happens at least in 1 more place.

@elacuesta
elacuesta merged commit 7aeb1df into main Jul 10, 2026
18 checks passed
@elacuesta
elacuesta deleted the pluggable-browser-providers branch July 10, 2026 15:28
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.

Firefox + custom executable_path works well here, sharing for others

2 participants