from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp('http://localhost:9222')
    page = browser.contexts[0].pages[0]
    
    # Đang ở trang root profile, click 'Edit profile'
    print('Clicking Edit profile button...')
    page.locator("div[role='button']:has-text('Edit profile')").first.click()
    page.wait_for_timeout(3000)
    page.screenshot(path=r'C:\Projects\Historical\FacebookAutoPoster\real_modal.png')
    print('Modal screenshot saved!')
    browser.close()
