github microsoft/playwright-python v1.18.0

latest releases: v1.43.0, v1.42.0, v1.41.2...
2 years ago

API Testing

Playwright for Python 1.18 introduces new API Testing that lets you send requests to the server directly from Python!
Now you can:

  • test your server API
  • prepare server side state before visiting the web application in a test
  • validate server side post-conditions after running some actions in the browser

To do a request on behalf of Playwright's Page, use new page.request API:

# Do a GET request on behalf of page
res = page.request.get("http://example.com/foo.json")

Read more in our documentation.

Web-First Assertions

Playwright for Python 1.18 introduces Web-First Assertions.

Consider the following example:

from playwright.sync_api import Page, expect

def test_status_becomes_submitted(page: Page) -> None:
    # ..
    page.click("#submit-button")
    expect(page.locator(".status")).to_have_text("Submitted")

Playwright will be re-testing the node with the selector .status until
fetched Node has the "Submitted" text. It will be re-fetching the node and
checking it over and over, until the condition is met or until the timeout is
reached. You can pass this timeout as an option.

Read more in our documentation.

Locator Improvements

New APIs & changes

Browser Versions

  • Chromium 99.0.4812.0
  • Mozilla Firefox 95.0
  • WebKit 15.4

This version was also tested against the following stable channels:

  • Google Chrome 97
  • Microsoft Edge 97

Don't miss a new playwright-python release

NewReleases is sending notifications on new releases.