Getting Started

Your First Workflow

The Pattern

Every GPAL workflow starts at the GPAL factory class. You create a Browser or Application object, navigate to your target, then build a chain of selector-plus-action steps. Each step is a Unit of Work. A selector that finds elements and an action that operates on them.

A Minimal Example

This example opens Chrome, navigates to a page, reads the h1 heading text into a grid, and prints it. This is the complete, runnable form of the simplest possible GPAL workflow.

using GenerallyPositive;

using GenerallyPositive.Browser;


var browser = GPAL.Browser

.WithBrowserType(BrowserType.Chrome)

.ToGPALObject();


browser.GoTo("https://example.com")

.WithSelector("h1")

.GetGrid(out var result);


Console.WriteLine(result[0][0]);

browser.Close();

NOTE

ToGPALObject() finalizes configuration and returns a reusable IBrowser you can hold across multiple workflow chains. You can omit it entirely and chain selectors and actions directly from GPAL.Browser -- GPAL manages the browser internally. Either way, the browser launches on the first action in the chain, not at configuration time.

What Just Happened

GPAL.Browser.WithBrowserType(BrowserType.Chrome).ToGPALObject() returned a reusable IBrowser. The browser launched when GoTo executed -- that is the first action in the chain. PuppeteerPort, GPAL's default automation engine, talks to Chrome directly over the Chrome DevTools Protocol (using SDi's own custom Puppeteer implementation) with no separate driver needed. WithSelector defined the element to find. GetGrid executed the find, collected the text content of all matched elements, and returned a grid where each matched element is a row.

WARNING

Close(true) terminates all processes associated with that browser, including driver processes. This matters because chromedriver or edgedriver can hang and fail to exit on their own. Use Close(true) as your last call before exiting, or whenever no more browser automation is needed. Close() (the default false) closes just this browser instance and leaves those processes running, so you can open another browser and reuse them.

💬 Ask GPAL