Url

Pre-Navigation Storage Actions

WithStorageType begins a storage definition and sets its type (cookie, localStorage, sessionStorage, indexedDb, cache). WithStorageKey sets the key for the storage item. WithStorageData sets the value to write for set operations.

WithStoragePath and WithStorageDomain restrict cookie scope. WithStorageStoreName sets the IndexedDB store name. WithDeleteAcrossOrigins controls whether delete operations cross origin boundaries. WithUserDefined stores a filter value a workflow can pick definitions out by.

A definition carries no action of its own. It says what storage is meant, and the workflow says what to do with it: RunGet, RunSet or RunDelete. Nothing runs on its own when the browser navigates.

Multiple definitions can be chained on a single GPALUrl. GetActions hands back the definitions registered on this URL, in the order they were added.

Where they run: going to the url with GoTo or Get makes its definitions the ones RunGet, RunSet and RunDelete use. To run them on a site before going there, put For(url) in front of the Run call. The browser stays on the page it is on, the action uses that url's definitions, and it lasts for that one action.

NOTE

A site's own cookies arrive with the very first request to it, so clearing them after GoTo still lets the site see one visit carrying them. Anti-bot vendors keep their verdict on a browser in such a cookie (Akamai's _abck, DataDome's datadome, Cloudflare's cf_clearance), so one flagged visit on a profile follows every visit after it. For(url) clears them before the visit, so the site only ever sees a clean one.

WARNING

WebDriver lists only the storage of the site the browser is on, and Firefox has no CDP to reach further, so For cannot reach another site from Selenium on Firefox. The action says so with a WARNING and finds nothing. Go to the site, run the action there, and reload. OttoMagic, Puppeteer, and Selenium on Chrome and Edge all reach any site.

Examples

GPAL Fluent: High-level fluent C# API

//The definitions say what storage is meant and the Run call says what to do with it. GoTo makes a url's definitions the ones a Run call uses; For uses another url's definitions for the next Run call without going there, which is how a workflow clears a site's cookies before visiting it. The browser has to be running, so For comes after the first GoTo or Get.

// declare what is meant: every cookie on gucci.com

GPALUrl gucci = "https://www.gucci.com/us/en/";

gucci.WithStorageType(WebsiteStorageType.cookie).WithStorageDomain("gucci.com");


// clear Akamai's verdict cookie before going there, then go

browser

.For(gucci)

.WithStorageKey("_abck")

.RunDelete(WebsiteStorageType.cookie)

.GoTo(gucci);


// read a cookie on the page the browser is on: going there made its definitions current

GPALUrl checkUrl = "https://example.com";

checkUrl.WithStorageType(WebsiteStorageType.cookie).WithStorageDomain("example.com").WithStorageKey("session_id");


browser

.GoTo(checkUrl)

.WithStorageKey("session_id")

.RunGet(WebsiteStorageType.cookie)

.GetStorageData(out string sessionId);


// set a localStorage value on the page

GPALUrl themedUrl = "https://app.example.com";

themedUrl.WithStorageType(WebsiteStorageType.localStorage).WithStorageKey("theme");


browser

.GoTo(themedUrl)

.WithStorageKey("theme")

.WithStorageData("dark")

.RunSet(WebsiteStorageType.localStorage);


// with nothing scoped, a Run call runs every definition of that type on the url

browser.RunDelete(WebsiteStorageType.cookie);

💬 Ask GPAL