From 0e82a0670d15c8886bb8fb33c3b72794494dbf69 Mon Sep 17 00:00:00 2001 From: Charles Stern <62192187+cisaacstern@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:14:34 -0400 Subject: [PATCH 1/6] add playwright install to conda test cmds --- meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/meta.yaml b/meta.yaml index 803565ac6..e547dfd35 100644 --- a/meta.yaml +++ b/meta.yaml @@ -40,6 +40,7 @@ test: # [build_platform == target_platform] - playwright.async_api commands: - playwright --help + - playwright install about: home: https://github.com/microsoft/playwright-python From ae9f1f392def43e442cbb67dd5b97cd7f2890c5d Mon Sep 17 00:00:00 2001 From: Charles Stern <62192187+cisaacstern@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:43:42 -0400 Subject: [PATCH 2/6] add example script tests to conda meta.yaml --- meta.yaml | 5 +++++ scripts/example_async.py | 16 ++++++++++++++++ scripts/example_sync.py | 15 +++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 scripts/example_async.py create mode 100644 scripts/example_sync.py diff --git a/meta.yaml b/meta.yaml index e547dfd35..39f51f648 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: @@ -41,6 +44,8 @@ test: # [build_platform == target_platform] commands: - playwright --help - playwright install + - 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..af0420378 --- /dev/null +++ b/scripts/example_async.py @@ -0,0 +1,16 @@ +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..af3ea0667 --- /dev/null +++ b/scripts/example_sync.py @@ -0,0 +1,15 @@ +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() From b247759fcd3d34f4c012a7d22b58569c177568a3 Mon Sep 17 00:00:00 2001 From: Charles Stern <62192187+cisaacstern@users.noreply.github.com> Date: Tue, 18 Mar 2025 17:55:06 -0400 Subject: [PATCH 3/6] actually revert noarch, and downgrade conda build py version --- .github/workflows/ci.yml | 2 +- .github/workflows/publish.yml | 2 +- meta.yaml | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) 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 39f51f648..8331b6758 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 From 74e06ca15156996d0f19bf11667f71f9bc675658 Mon Sep 17 00:00:00 2001 From: Charles Stern <62192187+cisaacstern@users.noreply.github.com> Date: Wed, 19 Mar 2025 10:06:53 -0400 Subject: [PATCH 4/6] lint --- scripts/example_async.py | 19 +++++++++++++++++-- scripts/example_sync.py | 18 ++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/scripts/example_async.py b/scripts/example_async.py index af0420378..d8e0cebde 100644 --- a/scripts/example_async.py +++ b/scripts/example_async.py @@ -1,4 +1,19 @@ +# 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 @@ -7,8 +22,8 @@ async def main() -> None: 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 page.goto("http://playwright.dev") + await page.screenshot(path=f"example-{browser_type.name}.png") await browser.close() diff --git a/scripts/example_sync.py b/scripts/example_sync.py index af3ea0667..ede4106a0 100644 --- a/scripts/example_sync.py +++ b/scripts/example_sync.py @@ -1,3 +1,17 @@ +# 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 @@ -6,8 +20,8 @@ def main() -> None: 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') + page.goto("http://playwright.dev") + page.screenshot(path=f"example-{browser_type.name}.png") browser.close() From 15b17adb801d69274b846f3ee3bf2e748f6ae2c3 Mon Sep 17 00:00:00 2001 From: Charles Stern <62192187+cisaacstern@users.noreply.github.com> Date: Wed, 19 Mar 2025 10:32:56 -0400 Subject: [PATCH 5/6] install --with-deps for conda build test --- meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta.yaml b/meta.yaml index 8331b6758..1c0136b9c 100644 --- a/meta.yaml +++ b/meta.yaml @@ -42,7 +42,7 @@ test: # [build_platform == target_platform] - playwright.async_api commands: - playwright --help - - playwright install + - playwright install --with-deps - python scripts/example_sync.py - python scripts/example_async.py From e8706df4ba98f228c521414d0d0285194111f9c2 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 31 Mar 2025 12:24:36 +0100 Subject: [PATCH 6/6] chore: fix tests --- scripts/example_async.py | 3 +-- scripts/example_sync.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/example_async.py b/scripts/example_async.py index d8e0cebde..9fe5b6b11 100644 --- a/scripts/example_async.py +++ b/scripts/example_async.py @@ -22,8 +22,7 @@ async def main() -> None: 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") + assert await page.evaluate("() => 11 * 11") == 121 await browser.close() diff --git a/scripts/example_sync.py b/scripts/example_sync.py index ede4106a0..0c65a5f07 100644 --- a/scripts/example_sync.py +++ b/scripts/example_sync.py @@ -20,8 +20,7 @@ def main() -> None: 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") + assert page.evaluate("() => 11 * 11") == 121 browser.close()