playwright-python
playwright-python copied to clipboard
[BUG] Exception raised when invoking page.pause() on Python 3.11 and above
Context:
- Playwright Version: v1.30.0
- Operating System: Windows
- Python version: 3.11.1
- Browser: All
Code Snippet
import asyncio
from playwright.async_api import async_playwright, Browser, Page
async def main() -> int:
async with async_playwright() as playwright:
browser: Browser = await playwright.chromium.launch()
page: Page = await browser.new_page()
await page.goto("https://github.com/microsoft/playwright-python")
await page.pause()
await browser.close()
return 0
if __name__ == "__main__":
raise SystemExit(asyncio.run(main()))
Describe the bug
When invoking page.pause() an exception is raised: TypeError: Passing coroutines is forbidden, use tasks explicitly.
The following code snippet is responsible for this behavior:
https://github.com/microsoft/playwright-python/blob/5ba82253c4e898d6217f3bca284114002dd3dfa7/playwright/_impl/_page.py#L956-L960
As per asyncio.wait: Changed in version 3.11: Passing coroutine objects to wait() directly is forbidden.
For context, this functionality has been deprecated since Python 3.8.