Skip to main content

Use UI5 selectors with Playwright

Project description

playwright-ui5-select

PyPI - Version

A mirror of the playwright-ui5 custom selector engine, to streamline its use in python.

This package:

  • mirrors the relevant distribution files css.js and xpath.js
  • reads file contents and exports it in a manner can be passed straight into the playwright api
  • also provides the raw data if needed

Installation

uv:

uv add playwright-ui5-select

pip:

pip install playwright-ui5-select

Usage

Given a Playwright instance, register one or both selector engines with .selectors.register().

from playwright_ui5_select import css, xpath

# name can be changed here from "ui5_css" to whatever you like
playwright.selectors.register("ui5_css", css)
playwright.selectors.register("ui5_xpath", xpath)

You can use the fixture supplied by playwright-python to register your selectors with the session-scoped Playwright instance:

# in conftest.py

@fixture(scope="session", autouse=True)
def _(playwright: Playwright):
    playwright.selectors.register("ui5_css", css)

The registered selector will now be available.

def test_basic(page: Page):
    page.goto("https://ui5.sap.com")
    page.click("ui5_css=sap.m.Button[text='Get Started with UI5']")

See the full api here.

Other uses

The package also exports *_raw variables for you to consume as you see fit:

from playwright_ui5_select import css_raw, xpath_raw

print(css_raw)
print(xpath_raw)

These do not include the extra IIFE code that returns the default exports as an expression.

You can also access the raw files directly with importlib.resources at import/ui5:

from importlib.resources import files

import playwright_ui5_select

data = files(playwright_ui5_select).joinpath("import").joinpath("ui5")

csspath = data.joinpath("css.js")

print("csspath", csspath)

print("css", csspath.read_text())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

playwright_ui5_select-0.0.14.tar.gz (322.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

playwright_ui5_select-0.0.14-py3-none-any.whl (294.3 kB view details)

Uploaded Python 3

File details

Details for the file playwright_ui5_select-0.0.14.tar.gz.

File metadata

File hashes

Hashes for playwright_ui5_select-0.0.14.tar.gz
Algorithm Hash digest
SHA256 0df152d44ffeb6d37799ea88a552e14579f6fed6818f3353dd3fc646cf7ca57b
MD5 183d536c53cfa940f0087ca3f77dcf8f
BLAKE2b-256 3a3aa6306b5f3ce116eaa38880d6e7d045855513610757eebb6685408e516dc7

See more details on using hashes here.

File details

Details for the file playwright_ui5_select-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for playwright_ui5_select-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 1bb3bc14bb27395d53655f689785705bf9b766a5959f8a970b3e970fb4114878
MD5 d77ad58053d33788a1ffbcb801530b8c
BLAKE2b-256 d8068cbead7f069a1a9c4457b89fc685905a67470dd157e441d525aad62864af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page