github microsoft/playwright-python v1.14.0

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

⚡️ New "strict" mode

Selector ambiguity is a common problem in automation testing. "strict" mode
ensures that your selector points to a single element and throws otherwise.

Pass strict = true into your action calls to opt in.

# This will throw if you have more than one button!
page.click('button', strict=true)

📍 New Locators API

Locator represents a view to the element(s) on the page. It captures the logic sufficient to retrieve the element at any given moment.

The difference between the Locator and ElementHandle is that the latter points to a particular element, while Locator captures the logic of how to retrieve that element.

Also, locators are "strict" by default!

locator = page.locator('button')
locator.click()

Learn more in the documentation.

🧩 Experimental React and Vue selector engines

React and Vue selectors allow selecting elements by its component name and/or property values. The syntax is very similar to attribute selectors and supports all attribute selector operators.

page.click('_react=SubmitButton[enabled=true]')
page.click('_vue=submit-button[enabled=true]')

Learn more in the react selectors documentation and the vue selectors documentation.

✨ New nth and visible selector engines

  • nth selector engine is equivalent to the :nth-match pseudo class, but could be combined with other selector engines.
  • visible selector engine is equivalent to the :visible pseudo class, but could be combined with other selector engines.
# select the first button among all buttons
button.click('button >> nth=0')
# or if you are using locators, you can use first(), nth() and last()
page.locator('button').first().click()

# click a visible button
button.click('button >> visible=true')

Browser Versions

  • Chromium 94.0.4595.0
  • Mozilla Firefox 91.0
  • WebKit 15.0

This version of Playwright was also tested against the following stable channels:

  • Google Chrome 92
  • Microsoft Edge 92

Don't miss a new playwright-python release

NewReleases is sending notifications on new releases.