Skip to content

[BUG] Exception raised when invoking page.pause() on Python 3.11 and above #1748

Closed
@anthonyprintup

Description

@anthonyprintup

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:

async def pause(self) -> None:
await asyncio.wait(
[self._browser_context._pause(), self._closed_or_crashed_future],
return_when=asyncio.FIRST_COMPLETED,
)

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [BUG] Exception raised when invoking page.pause() on Python 3.11 and above · Issue #1748 · microsoft/playwright-python