diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80dd92245..0a6d8fcd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,7 +169,7 @@ jobs: - name: Get conda uses: conda-incubator/setup-miniconda@v3 with: - python-version: 3.12 + python-version: 3.9 channels: conda-forge miniconda-version: latest - name: Prepare diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 54c7ab80e..b682372fd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,7 +31,7 @@ jobs: - name: Get conda uses: conda-incubator/setup-miniconda@v3 with: - python-version: 3.12 + python-version: 3.9 channels: conda-forge miniconda-version: latest - name: Prepare diff --git a/meta.yaml b/meta.yaml index 803565ac6..1c0136b9c 100644 --- a/meta.yaml +++ b/meta.yaml @@ -6,7 +6,6 @@ source: path: . build: - noarch: python number: 0 script: "{{ PYTHON }} -m pip install . --no-deps -vv" binary_relocation: False @@ -32,6 +31,9 @@ requirements: - pyee>=12,<13 test: # [build_platform == target_platform] + files: + - scripts/example_sync.py + - scripts/example_async.py requires: - pip imports: @@ -40,6 +42,9 @@ test: # [build_platform == target_platform] - playwright.async_api commands: - playwright --help + - playwright install --with-deps + - python scripts/example_sync.py + - python scripts/example_async.py about: home: https://github.com/microsoft/playwright-python diff --git a/scripts/example_async.py b/scripts/example_async.py new file mode 100644 index 000000000..9fe5b6b11 --- /dev/null +++ b/scripts/example_async.py @@ -0,0 +1,30 @@ +# Copyright (c) Microsoft Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio + +from playwright.async_api import async_playwright + + +async def main() -> None: + async with async_playwright() as p: + for browser_type in [p.chromium, p.firefox, p.webkit]: + browser = await browser_type.launch() + page = await browser.new_page() + assert await page.evaluate("() => 11 * 11") == 121 + await browser.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/scripts/example_sync.py b/scripts/example_sync.py new file mode 100644 index 000000000..0c65a5f07 --- /dev/null +++ b/scripts/example_sync.py @@ -0,0 +1,28 @@ +# Copyright (c) Microsoft Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from playwright.sync_api import sync_playwright + + +def main() -> None: + with sync_playwright() as p: + for browser_type in [p.chromium, p.firefox, p.webkit]: + browser = browser_type.launch() + page = browser.new_page() + assert page.evaluate("() => 11 * 11") == 121 + browser.close() + + +if __name__ == "__main__": + main()