Releases: microsoft/playwright-python
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
v1.36.0
v1.35.0
Highlights
-
New option
mask_color
for methodsPage.screenshot()
andLocator.screenshot()
to change default masking color. -
New
uninstall
CLI command to uninstall browser binaries:$ playwright uninstall # remove browsers installed by this installation $ playwright uninstall --all # remove all ever-install Playwright browsers
Browser Versions
- Chromium 115.0.5790.13
- Mozilla Firefox 113.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 114
- Microsoft Edge 114
v1.34.0
Highlights
-
New
Locator.and_
to create a locator that matches both locators.button = page.get_by_role("button").and_(page.get_by_title("Subscribe"))
-
Its now possible to set a global expect timeout and change the 5 second default:
from playwright.sync_api import expect expect.set_options(timeout=10_000)
-
New events
BrowserContext.on("console")
andBrowserContext.on("dialog")
to subscribe to any dialogs
and console messages from any page from the given browser context. Use the new propertiesConsoleMessage.page
andDialog.page
to pin-point event source.
Browser Versions
- Chromium 114.0.5735.26
- Mozilla Firefox 113.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 113
- Microsoft Edge 113
v1.33.0
Highlights
Locators Update
-
Use
Locator.or_
to create a locator that matches either of the two locators.
Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead.
In this case, you can wait for either a "New email" button, or a dialog and act accordingly:new_email = page.get_by_role("button", name="New email") dialog = page.get_by_text("Confirm security settings") expect(new_email.or_(dialog)).is_visible() if (dialog.is_visible()) page.get_by_role("button", name="Dismiss").click() new_email.click()
-
Use new options
has_not
andhas_not_text
inLocator.filter
to find elements that do not match certain conditions.row_locator = page.locator("tr") row_locator .filter(has_not_text="text in column 1") .filter(has_not=page.get_by_role("button", name="column 2 button")) .screenshot()
-
Use new web-first assertion
expect(locator).to_be_attached()
to ensure that the element
is present in the page's DOM. Do not confuse with theexpect(locator).to_be_visible()
that ensures that
element is both attached & visible.
New APIs
Locator.or
- New option
has_not
inLocator.filter
- New option
has_not_text
inLocator.filter
expect(locator).to_be_attached
- New option
timeout
inmethod: Route.fetch
⚠️ Breaking change
- The
mcr.microsoft.com/playwright/python:v1.33.0
now serves a Playwright image based on Ubuntu Jammy.
To use the focal-based image, please usemcr.microsoft.com/playwright/python:v1.33.0-focal
instead.
Browser Versions
- Chromium 113.0.5672.53
- Mozilla Firefox 112.0
- WebKit 16.4
This version was also tested against the following stable channels:
- Google Chrome 112
- Microsoft Edge 112