Automation Targets

Browser Automation Basics

GPAL.Browser is the entry point for web automation. GoTo drives a real browser through a page; Get fetches HTML directly with no browser at all. Tabs, history, and the server's last response code round out the basics.

GoTo vs Get

GoTo and Get both launch or reuse a real browser and navigate it to a URL. The page renders, scripts run, and GetPageSource returns the rendered DOM either way, not a raw HTTP response. The difference is headless mode: GoTo navigates using whatever headless setting is currently configured (see WithUseHeadless), while Get forces headless mode for that navigation regardless of the current setting. Get is the lighter-weight choice when the workflow does not need a visible browser window. An API response, a sitemap, server-rendered content. While GoTo is useful when the workflow needs (or benefits from) a visible, interactive browser.

// GoTo - navigates using whatever headless setting is currently configured

GPAL.Browser

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

.WithSelector("h1")

.GetGrid(out var heading);

// Get - same browser, but forces headless mode for this navigation

GPAL.Browser

.Get("https://api.example.com/data")

.GetPageSource(out string html);

TIP

Close ends the session. Close(true). The default. Also kills the underlying WebDriver process so nothing is left running; pass false to disconnect while leaving the browser window open.

Tabs and History

NewTab opens a new browser tab at the given URL and NextTab switches the tab GPAL is currently automating. Useful when a workflow opens several result pages and needs to process each in turn. Back and Forward step through the active tab's navigation history, the same as clicking a browser's back and forward buttons.

GPAL.Browser

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

.NewTab("https://example.com/reports")

.NextTab();

// History navigation

GPAL.Browser

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

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

.Back

.Forward;

Checking the Server's Response Code

ServerResponseCode holds the HTTP status code from the most recent GoTo or Get, and it's available no matter which automation engine you're using. Selenium, Puppeteer, or OttoMagic. 0 means GPAL couldn't determine a status, -1 means an error occurred while checking. For Puppeteer and OttoMagic this comes straight from the Chrome DevTools Protocol; for Selenium. Which has no built-in way to read response codes. GPAL reads the browser's performance logs to extract it, so the value is available there too without any extra setup.

browser.GoTo("https://example.com/maybe-missing-page");

if (404 == browser.ServerResponseCode)

{

GPAL.PublishSimpleEvent(GPALEventType.WARN, "Page not found, skipping");

}

else if (200 == browser.ServerResponseCode)

{

// proceed with the workflow

}

WARNING

GPAL extracts the Selenium response code from the browser's performance logs, which depend on the driver and browser version exposing them. If the logs aren't available, ServerResponseCode falls back to 0 (undetermined) rather than failing the workflow.