Launcher setup

Create a “CDP Chrome” launcher for a debug-enabled, automation-only Chrome

The connect and extension transports drive your everyday browser, but sometimes that’s exactly what you don’t want: an agent filling forms shouldn’t see your banking session. fastcdp-setup creates an OS launcher (“CDP Chrome”) that starts your installed Chrome with --remote-debugging-port and its own profile directory, so you get a separate Chrome that’s only logged in to the things you want automated, ready for CDP.remote(). On macOS it’s a real app bundle in ~/Applications, on Linux a .desktop entry, on Windows a Start Menu shortcut.

from fastcore.test import test_eq

source

chrome_path

def chrome_path():

Find the installed Chrome (or Chromium) executable

Each platform builder takes explicit chrome, port, profile, and dest paths, so they can be exercised anywhere; main picks the right one and the conventional destination for the OS.

The bundle is three files: a plist, a one-line launcher script, and the icon. Building one into a temp dir shows the structure:

app = _mac_app(Path('/usr/bin/true'), 'CDP Chrome', 9223, Path('/tmp/prof'), Path('/tmp/fastcdp-test-apps'))
print((app/'Contents/MacOS/launch').read_text())
test_eq((app/'Contents/Resources/icon.icns').exists(), True)

A .desktop entry plus a hicolor icon is the whole story on Linux:

desk = _linux_app(Path('/usr/bin/true'), 'CDP Chrome', 9223, Path('/tmp/prof'), Path('/tmp/fastcdp-test-share'))
print(desk.read_text())
test_eq(desk.name, 'cdp-chrome.desktop')

Windows gets a Start Menu shortcut built by PowerShell’s WScript.Shell COM object; the icon is copied next to the profile so the .lnk has a stable path to point at.


source

main

def main(
    port:int=9223, # Debug port (`CDP.remote`'s default; 9222 would clash with the everyday browser's built-in debugging)
    profile:str=None, # Chrome profile dir (default: `~/.cache/fastcdp/cdp-chrome`)
    name:str='CDP Chrome', # Launcher name
):

Create an OS launcher for a debug-enabled Chrome with its own profile, ready for CDP.remote

fastcdp-setup is registered as a console script, so after pip install fastcdp it’s one command with sensible defaults. It shares CDP.remote’s default port 9223, so the pair works with no arguments on either side; 9222 is avoided because a main browser with built-in remote debugging enabled already holds it.