Releases: microsoft/playwright-python
v1.43.0
New APIs
-
Method BrowserContext.clear_cookies([options]) now supports filters to remove only some cookies.
# Clear all cookies. context.clear_cookies() # New: clear cookies with a particular name. context.clear_cookies(name="session-id") # New: clear cookies for a particular domain. context.clear_cookies(domain="my-origin.com")
-
New method locator.content_frame converts a {@link Locator} object to a FrameLocator. This can be useful when you have a Locator object obtained somewhere, and later on would like to interact with the content inside the frame.
locator = page.locator("iframe[name='embedded']") # ... frame_locator = locator.content_frame frame_locator.getByRole("button").click()
-
New method frameLocator.owner converts a FrameLocator object to a Locator. This can be useful when you have a FrameLocator object obtained somewhere, and later on would like to interact with the
iframe
element.frame_locator = page.frame_locator("iframe[name='embedded']") # ... locator = frame_locator.owner expect(locator).to_be_visible()
-
Conda builds are now published for macOS-arm64 and Linux-arm64.
Browser Versions
- Chromium 124.0.6367.8
- Mozilla Firefox 124.0
- WebKit 17.4
This version was also tested against the following stable channels:
- Google Chrome 123
- Microsoft Edge 123
v1.42.0
New Locator Handler
New method page.add_locator_handler(locator, handler) registers a callback that will be invoked when specified element becomes visible and may block Playwright actions. The callback can get rid of the overlay. Here is an example that closes a cookie dialog when it appears.
# Setup the handler.
page.add_locator_handler(
page.get_by_role("heading", name="Hej! You are in control of your cookies."),
lambda: page.get_by_role("button", name="Accept all").click(),
)
# Write the test as usual.
page.goto("https://www.ikea.com/")
page.get_by_role("link", name="Collection of blue and white").click()
expect(page.get_by_role("heading", name="Light and easy")).to_be_visible()
New APIs
- page.pdf([options]) accepts two new options
tagged
andoutline
.
Announcements
⚠️ Ubuntu 18 is not supported anymore.
Browser Versions
- Chromium 123.0.6312.4
- Mozilla Firefox 123.0
- WebKit 17.4
This version was also tested against the following stable channels:
- Google Chrome 122
- Microsoft Edge 123
v1.41.2
Highlights
#2258 - [REGRESSION] Failing step is not highlighted in red in actions panel for versions after 1.39.0
microsoft/playwright#29123 - [REGRESSION] route.continue: Protocol error (Fetch.continueRequest): Invalid InterceptionId.
Browser Versions
- Chromium 121.0.6167.57
- Mozilla Firefox 121.0
- WebKit 17.4
This version was also tested against the following stable channels:
- Google Chrome 120
- Microsoft Edge 120
v1.41.1
Highlights
microsoft/playwright#29067 - [REGRESSION] Codegen/Recorder: not all clicks are being actioned nor recorded
microsoft/playwright#29019 - [REGRESSION] trace.playwright.dev does not currently support the loading from URL
Browser Versions
- Chromium 121.0.6167.57
- Mozilla Firefox 121.0
- WebKit 17.4
This version was also tested against the following stable channels:
- Google Chrome 120
- Microsoft Edge 120
v1.41.0
New APIs
- New method page.unroute_all() removes all routes registered by page.route() and page.route_from_har(). Optionally allows to wait for ongoing routes to finish, or ignore any errors from them.
- New method browserContext.unroute_all() removes all routes registered by browserContext.route() and browserContext.route_from_har(). Optionally allows to wait for ongoing routes to finish, or ignore any errors from them.
- New option
style
in page.screenshot() and locator.screenshot() to add custom CSS to the page before taking a screenshot.
Browser Versions
- Chromium 121.0.6167.57
- Mozilla Firefox 121.0
- WebKit 17.4
This version was also tested against the following stable channels:
- Google Chrome 120
- Microsoft Edge 120
v1.40.0
Test Generator Update
New tools to generate assertions:
- "Assert visibility" tool generates expect(locator).to_be_visible().
- "Assert value" tool generates expect(locator).to_have_value(value).
- "Assert text" tool generates expect(locator).to_contain_text(expected).
Here is an example of a generated test with assertions:
from playwright.sync_api import Page, expect
def test_example(page: Page) -> None:
page.goto("https://playwright.dev/")
page.get_by_role("link", name="Get started").click()
expect(page.get_by_label("Breadcrumbs").get_by_role("list")).to_contain_text("Installation")
expect(page.get_by_label("Search")).to_be_visible()
page.get_by_label("Search").click()
page.get_by_placeholder("Search docs").fill("locator")
expect(page.get_by_placeholder("Search docs")).to_have_value("locator");
New APIs
- Option
reason
in page.close([options]), browserContext.close([options]) and browser.close([options]). Close reason is reported for all operations interrupted by the closure. - Option
firefox_user_prefs
in browserType.launch_persistent_context(userDataDir[, options]).
Other Changes
- Method download.path() throws an error for failed and cancelled downloads.
Browser Versions
- Chromium 120.0.6099.28
- Mozilla Firefox 119.0
- WebKit 17.4
This version was also tested against the following stable channels:
- Google Chrome 119
- Microsoft Edge 119
v1.39.0
v1.38.0
Trace Viewer Updates
- Zoom into time range.
- Network panel redesign.
New APIs
Deprecations
- The following methods were deprecated:
page.type()
,frame.type()
,locator.type()
andelementHandle.type()
.
Please uselocator.fill()
instead which is much faster. Uselocator.press_sequentially()
only if there is a
special keyboard handling on the page, and you need to press keys one-by-one.
Browser Versions
- Chromium 117.0.5938.62
- Mozilla Firefox 117.0
- WebKit 17.0
This version was also tested against the following stable channels:
- Google Chrome 116
- Microsoft Edge 116
v1.37.0
Highlights
-
New --full-page-screenshot command line flag allows taking a
full page screenshot on failure. -
It is now possible to override the context options for a single test by using the browser_context_args marker.
-
pytest-playwright
is now also getting published on Anaconda
📚 Debian 12 Bookworm Support
Playwright now supports Debian 12 Bookworm on both x86_64 and arm64 for Chromium, Firefox and WebKit.
Let us know if you encounter any issues!
Linux support looks like this:
Ubuntu 20.04 | Ubuntu 22.04 | Debian 11 | Debian 12 | |
---|---|---|---|---|
Chromium | ✅ | ✅ | ✅ | ✅ |
WebKit | ✅ | ✅ | ✅ | ✅ |
Firefox | ✅ | ✅ | ✅ | ✅ |
Browser Versions
- Chromium 116.0.5845.82
- Mozilla Firefox 115.0
- WebKit 17.0
This version was also tested against the following stable channels:
- Google Chrome 115
- Microsoft Edge 115