fix: use launchPersistentContext for Chrome extension loading

Playwright's chromium.launch() silently ignores --load-extension.
Switch to launchPersistentContext with ignoreDefaultArgs to remove
--disable-extensions flag. Use bundled Chromium (real Chrome blocks
unpacked extensions). Fixed port 34567 for CDP mode so the extension
auto-connects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-03-21 15:09:42 -07:00
parent 803bee9cfe
commit 3814a12ab2
2 changed files with 51 additions and 28 deletions
+2
View File
@@ -365,9 +365,11 @@ Refs: After 'snapshot', use @e1, @e2... as selectors:
console.log('Launching real Chrome browser...');
try {
// Start server with CDP flag — server.ts will use channel:chrome
// Use a well-known port so the Chrome extension auto-connects
const newState = await startServer({
BROWSE_CDP_URL: 'channel:chrome',
BROWSE_CDP_PORT: '0',
BROWSE_PORT: '34567',
});
// Print connected status