Skip to content

[BUG] Page.goto() not returning #1280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OxNinja opened this issue May 3, 2022 · 1 comment
Closed

[BUG] Page.goto() not returning #1280

OxNinja opened this issue May 3, 2022 · 1 comment

Comments

@OxNinja
Copy link

OxNinja commented May 3, 2022

Context:

  • Playwright Version: 1.21.0
  • Operating System: Linux
  • Python version: 3.10.4
  • Browser: Chrome
  • Extra: USB Android device

Code Snippet

Need an USB device with USB debug enabled (connected with ADB)

Requires ppadb playwright and a running ADB server (adb start-server)

import asyncio

from playwright.async_api import async_playwright
from ppadb.client import Client


# This function works
def forward(port):
    """Creates a port forwarding for one device"""
    client = Client()
    device = client.devices()[0]
    device.forward(local=f"tcp:{port}", remote="localabstract:chrome_devtools_remote")


# This function blocks on the goto()
async def run(port):
    """Connects to a USB device over CDP (via the port forwarding) and visit an URL"""
    async with async_playwright() as pw:
        browser = await pw.chromium.connect_over_cdp(f"http://localhost:{port}")

    # Infinite wait
    await browser.contexts[0].pages[0].goto("https://google.com")


if __name__ == '__main__':
    forward_port = 9001

    # Create port forwarding
    forward(forward_port)

    # Run the async function
    asyncio.run(run(forward_port))

Describe the bug

The line await browser.contexts[0].pages[0].goto("https://google.com") never returns and the script is stuck in an infinite loop.

My guess is that thegoto method is not compatible with remote CDP:

  • The browser object is defined with no error
  • I can open a new page/tab with await browser.contexts[0].new_page()
  • The browser.contexts[0].pages[0] object is a Page with all the corresponding attributes (including the method goto)
@mxschmitt
Copy link
Member

Connecting to an android device is not supported out of the box, I'd recommend to wait until #1281 is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants