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..6f43610a9 100644 --- a/meta.yaml +++ b/meta.yaml @@ -32,6 +32,9 @@ requirements: - pyee>=12,<13 test: # [build_platform == target_platform] + files: + - scripts/example_sync.py + - scripts/example_async.py requires: - pip imports: @@ -40,6 +43,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..e8f9966c3 --- /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.s +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() + await page.goto("http://playwright.dev") + await page.screenshot(path=f"example-{browser_type.name}.png") + 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..ede4106a0 --- /dev/null +++ b/scripts/example_sync.py @@ -0,0 +1,29 @@ +# 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() + page.goto("http://playwright.dev") + page.screenshot(path=f"example-{browser_type.name}.png") + browser.close() + + +if __name__ == "__main__": + main()