File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ requirements:
3232 - pyee>=12,<13
3333
3434test : # [build_platform == target_platform]
35+ files :
36+ - scripts/example_sync.py
37+ - scripts/example_async.py
3538 requires :
3639 - pip
3740 imports :
@@ -41,6 +44,8 @@ test: # [build_platform == target_platform]
4144 commands :
4245 - playwright --help
4346 - playwright install
47+ - python scripts/example_sync.py
48+ - python scripts/example_async.py
4449
4550about :
4651 home : https://github.com/microsoft/playwright-python
Original file line number Diff line number Diff line change 1+ import asyncio
2+ from playwright .async_api import async_playwright
3+
4+
5+ async def main () -> None :
6+ async with async_playwright () as p :
7+ for browser_type in [p .chromium , p .firefox , p .webkit ]:
8+ browser = await browser_type .launch ()
9+ page = await browser .new_page ()
10+ await page .goto ('http://playwright.dev' )
11+ await page .screenshot (path = f'example-{ browser_type .name } .png' )
12+ await browser .close ()
13+
14+
15+ if __name__ == "__main__" :
16+ asyncio .run (main ())
Original file line number Diff line number Diff line change 1+ from playwright .sync_api import sync_playwright
2+
3+
4+ def main () -> None :
5+ with sync_playwright () as p :
6+ for browser_type in [p .chromium , p .firefox , p .webkit ]:
7+ browser = browser_type .launch ()
8+ page = browser .new_page ()
9+ page .goto ('http://playwright.dev' )
10+ page .screenshot (path = f'example-{ browser_type .name } .png' )
11+ browser .close ()
12+
13+
14+ if __name__ == "__main__" :
15+ main ()
You can’t perform that action at this time.
0 commit comments