PuppeteerClient

PuppeteerClient - In-Process CDP Automation

PuppeteerClient is the in-process equivalent of RESTClient - the same fluent endpoint-based API, but commands are sent directly over a Chrome DevTools Protocol (CDP) connection instead of through the OttoMagic REST API.

PuppeteerClient is the in-process equivalent of RESTClient - the same fluent endpoint-based API, but commands are sent directly over a Chrome DevTools Protocol (CDP) connection instead of through the OttoMagic REST API.

Despite the name, PuppeteerClient (and the PuppeteerCommunicator layer underneath it) is GPAL's own from-scratch implementation of Chrome DevTools Protocol automation in C# - it is not a wrapper, binding, or port of the Node.js Puppeteer library, PuppeteerSharp, or any other existing Puppeteer package. The name describes what it does (puppeteer-style CDP control of the browser), not where the code came from. GPAL.PuppeteerClient (or browser.PuppeteerClient on a live Browser instance) gives you the same WithEndpoint/Execute fluent pattern as RESTClient, except every call is dispatched directly to the browser over CDP via the PuppeteerCommunicator websocket connection - there is no HTTP hop and no separate OttoMagic REST process to run. PuppeteerClient is the engine GPAL uses internally whenever WithUseAutomationEngine is set to PuppeteerPort, PuppeteerPortHW, PuppeteerPipe, or PuppeteerPipeHW - all of the Browser fluent methods (GoTo, WithSelector, LeftClick, FillInFrom, GetGrid, WaitFor, etc.) are translated into PuppeteerClient endpoint calls under the hood for these engines. You normally never call PuppeteerClient directly - it is documented here for advanced workflows that need to issue a CDP-backed call that does not have a Browser-level fluent equivalent yet, or that want to bypass the Browser unit-of-work bookkeeping entirely.

TIP

PuppeteerClient implements the same ApiEndpoint enum and endpoint map as RESTClient (see RESTClient - Setup and Configuration). Anything documented for RESTClient's endpoints applies to PuppeteerClient's parameters as well - the difference is transport (CDP vs HTTP) and that PuppeteerClient requires an active Browser using a Puppeteer-based engine.

Examples

GPAL Fluent: High-level fluent C# API

//WithUseAutomationEngine is a one-time browser session setting - once the browser is open with the Puppeteer engine selected, every fluent Browser call (LeftClick, FillInFrom, GetGrid, WaitFor, etc.) is carried out via PuppeteerClient/PuppeteerCommunicator instead of WebDriver or the OttoMagic extension.

// Browser using the Puppeteer (CDP) engine GPAL.Browser .WithUseAutomationEngine(AutomationEngine.PuppeteerPort) .GoTo("https://example.com") .WithSelector("#submit") .LeftClick(); // Accessing PuppeteerClient directly from a live Browser var browser = GPAL.Browser .WithUseAutomationEngine(AutomationEngine.PuppeteerPort) .GoTo("https://example.com") .ToGPALObject(); string title = browser.PuppeteerClient .Evaluate("string(//title)") .Execute();