Skip to content

Instantly share code, notes, and snippets.

@lifeart
Created March 16, 2023 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lifeart/61dcd1b1833cd5dcb8d0823bfd8bf248 to your computer and use it in GitHub Desktop.
Save lifeart/61dcd1b1833cd5dcb8d0823bfd8bf248 to your computer and use it in GitHub Desktop.
Playwright using current browser
// ref https://twitter.com/underoot/status/1633430089802084352?s=52&t=0yc3BUdFiWnN-uQfrkt3xw
(async () = {
const port = 12345; // N port
const browser = await chromium. connectOverCDP(`http://localhost:${port}`);
const defaultContext = browser. contexts()[0];
const page await defaultContext.newPage();
// Do something with page
});
/*
~ /Applications/Google\ Chrome.app/Contents/Mac0S/Google\ Chrome \
-profile-directory="Profile 1" \
-remote-debugging-port=N
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment