PuppeteerClient

Executing CDP Commands via PuppeteerClient

PuppeteerClient mirrors RESTClient's Execute family - Execute(), Execute<T>(), ExecuteAsync(), AndThen() - plus navigation, element interaction, and DOM query methods backed directly by CDP. All of it runs on GPAL's own custom CDP implementation, not a Puppeteer-library wrapper.

PuppeteerClient mirrors RESTClient's Execute family - Execute(), Execute<T>(), ExecuteAsync(), AndThen() - plus navigation, element interaction, and DOM query methods backed directly by CDP. All of it runs on GPAL's own custom CDP implementation, not a Puppeteer-library wrapper.

WithEndpoint(string) or WithEndpoint(ApiEndpoint) selects the operation, exactly as on RESTClient. GoTo, GoToTab, GoToWindow, InElement, LeftClick, FillInOverwrite, QuerySelector, QuerySelectors, and Evaluate configure the same parameters RESTClient uses for those endpoints. Execute() runs the command synchronously and returns the result as a string; Execute<T>() deserializes the CDP result to a typed object (including JObject for raw CDP responses); ExecuteAsync() and ExecuteAsync<T>() are the async variants; AndThen() executes immediately and returns the client for continued chaining.

WARNING

Unlike RESTClient, PuppeteerClient does not need WithAPIBase - it is already bound to the live Browser's CDP connection via PuppeteerCommunicator. Calling it without an open Browser using a Puppeteer-based engine will fail.

Examples

GPAL Fluent: High-level fluent C# API

//QuerySelector and Evaluate return an element ID string usable by subsequent interaction calls, the same as RESTClient. Execute<JObject>() is useful for endpoints that return structured CDP responses you want to inspect directly rather than deserialize to a specific type.

// Query for an element by CSS and click it var browser = GPAL.Browser .WithUseAutomationEngine(AutomationEngine.PuppeteerPort) .GoTo("https://example.com") .ToGPALObject(); string elementId = browser.PuppeteerClient .QuerySelector(".product-title") .Execute(); browser.PuppeteerClient .LeftClick(elementId) .Execute(); // Get a typed JObject result from a raw CDP-backed call var attrs = browser.PuppeteerClient .GetDomAttributes(elementId) .Execute<Newtonsoft.Json.Linq.JObject>(); // Chain with AndThen browser.PuppeteerClient .GoTo(GPAL.Url().ForUrl("https://example.com/next").ToGPALObject()) .AndThen() .QuerySelector(".confirmation") .Execute();