Skip to main content

New Launch Script Functions, Variables, and the .optional() Modifier

Improvement

Launch scripts can now do considerably more before A11y Pulse audits a page. Three new functions let you prepare browser state that a login form alone cannot reach. setCookie(name, value) and setLocalStorage(key, value) seed the values an app expects to already be present, which is useful for skipping consent banners, feature flags, or session hints that would otherwise get in the way of the scan. totp(secret("...")) generates a time-based one-time password from a stored secret so you can drive a login flow that is protected by multi-factor authentication.

Three new variables give each script access to information about the scan it is running inside. PAGE_URL resolves to the URL being scanned, SCAN_DATETIME to an ISO timestamp for the run, and RANDOM_STRING to a fresh random value that is stable for the duration of a single scan. They are handy when a script needs to build a unique identifier, stamp a request, or navigate relative to the page under test.

Finally, the new .optional() modifier marks a step that is allowed to fail without aborting the rest of the script. Append it to any instruction and A11y Pulse will move on to the next step if that instruction errors or times out, which keeps a scan alive when a script has to cope with a cookie prompt or interstitial that only appears some of the time.

navigate(PAGE_URL);
setCookie("consent", "accepted");
click(".dismiss-banner").optional();
fill("#code", totp(secret("TOTP")));
submit("form:has(input[name=password])");