Skip to content

can't get browser's context pages after connect_over_cdp #679

@DeleteXso

Description

@DeleteXso

Test on Chrome Version 90.0.4430.212 (Official Build) (64-bit) (Windows 10 20H2 OS Build 19042.928)
chrome lunched with "--remote-debugging-port=9222"

code:

##########
from playwright.sync_api import sync_playwright
playwright = sync_playwright().start()
chrome = playwright.chromium.connect_over_cdp("http://localhost:9222")
c1 = chrome.contexts[0] # default context
print(c1.pages) # []
print(len(c1.pages)) # 0
##########

but i am able to get all the opened pages after i open a new_page:

##########
from playwright.sync_api import sync_playwright
playwright = sync_playwright().start()
chrome = playwright.chromium.connect_over_cdp("http://localhost:9222")
c1 = chrome.contexts[0]
c1.new_page()
print(c1.pages)
print(len(c1.pages)) # 6 (5 opened pages + the new page)
##########

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions