aeat.adapters.outbound.aeat.browser.evasion module

Anti-bot evasion strategies for Playwright contexts.

adapters.outbound.aeat.browser.BrowserSession applies an EvasionStrategy after creating each Playwright BrowserContext and before returning it to auth providers or Sede readers. The default PlaywrightStealthEvasion delegates to the optional playwright-stealth package and raises BrowserEvasionError with the browser-extra install hint when that package is unavailable.

See also

adapters.outbound.aeat.browser.BrowserSession.create_context()

Applies the configured evasion strategy during context preparation.

adapters.outbound.aeat.browser.BrowserFailureMode

Carries EVASION_FAILED when strategy application fails inside the central session wrapper.

class EvasionStrategy(*args, **kwargs)[source]

Bases: Protocol

Protocol for applying evasion techniques to a Playwright context.

Custom implementations can be supplied to BrowserSession tests or adapter callers; production code defaults to PlaywrightStealthEvasion.

async apply(context)[source]

Apply anti-bot evasion techniques to the given context.

Parameters:

context (BrowserContext) – The Playwright BrowserContext to patch.

Return type:

None

class PlaywrightStealthEvasion[source]

Bases: object

Evasion strategy backed by the playwright-stealth package.

Targets the playwright-stealth 2.x class-based API (Stealth().apply_stealth_async). The 1.x module-level stealth_async helper was removed upstream.

async apply(context)[source]

Apply playwright-stealth patches to context.

Parameters:

context (BrowserContext) – The Playwright BrowserContext to patch.

Raises:

BrowserEvasionError – If the playwright-stealth package is not installed.

Return type:

None