-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Open
Description
Version
1.58.0
Steps to reproduce
When connecting to Chrome via chromium.connectOverCDP(), pages opened through Chrome shortcuts (possibly PWA or special app pages) exhibit the following behavior:
page.url()returns an empty string""page.title()times out indefinitely- However, native CDP commands work perfectly
-
Open a page via Chrome shortcut (or PWA installation)
- Example: Right-click Chrome shortcut → Open as specific page
- Or install PWA from a website
-
Start Chrome with remote debugging:
chrome.exe --remote-debugging-port=9222
-
Connect via Playwright:
import { chromium } from 'playwright'; const browser = await chromium.connectOverCDP('http://localhost:9222'); const context = browser.contexts()[0]; const pages = context.pages(); for (const page of pages) { console.log('URL:', page.url()); // Some pages return "" console.log('Title:', await page.title()); // Times out }
-
Observe that shortcut/PWA pages return empty URL and timeout
Expected behavior
Since CDP layer works perfectly:
page.url()should return the actual URLpage.title()should return the page title- Both should work consistently regardless of how the page was opened
Actual behavior
page.url()returns""page.title()times out- CDP commands work fine
Additional context
Workaround
async function getURLSafe(page) {
const url = page.url();
if (url) return url;
// Fallback to CDP
const cdp = await page.context().newCDPSession(page);
const history = await cdp.send('Page.getNavigationHistory');
await cdp.detach();
return history.entries[history.currentIndex]?.url || '';
}
async function getTitleSafe(page) {
try {
return await Promise.race([
page.title(),
new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), 2000))
]);
} catch {
const cdp = await page.context().newCDPSession(page);
const history = await cdp.send('Page.getNavigationHistory');
await cdp.detach();
return history.entries[history.currentIndex]?.title || '';
}
}Environment
**Playwright Version**: 1.58.0 (Latest)
**Node.js Version**: 18+
**OS**: Windows 10/11
**Browser**: Chrome (connected via CDP)
**Mode**: connectOverCDPMetadata
Metadata
Assignees
Labels
No labels