waft.actions.system_actions.browser_actions module

class waft.actions.system_actions.browser_actions.BrowserActions(node: BaseNode)

Bases: object

Actions related to test system browser instances.

browser_context(browser: Browser, trace_file_prefix: str, storage_state: StorageState | None = None) Generator[BrowserContext, Any, None]

Context manager to yield a new Playwright browser context with advanced tracing enabled on the test node. Closes context and pages on exit.

Parameters:
  • browser (Browser) – Playwright browser instance

  • trace_file_prefix (str) – Filename prefix to apply to timestamped trace files

  • storage_state (StorageState) – Browser cache to reuse in the new context

Yields:

BrowserContext – Playwright BrowserContext object to be used for navigation

property browser_session: Generator[Browser, Any, None]

Context manager to yield a new Playwright browser session on the test node. Closes session on exit.

is_dns_blocked(domain: str, retry_on: Literal['blocked', 'unblocked'] | None, timeout: int = 180) bool

Return a boolean indicating if the given domain is blocked by DNS policy.

Parameters:
  • domain – URL string of domain to check for being blocked

  • retry_on – Argument to retry based on the returned value (wait <timeout> seconds for a given outcome)

  • timeout – Max time to retry for (default 30 seconds)

is_http_blocked(browser: Browser, domain: str, retry_on: Literal['blocked', 'unblocked'] | None, timeout: int = 180, page_output: Path | None = None) bool

Return a boolean indicating if the given domain is blocked by HTTP policy.

Parameters:
  • browser – Playwright browser session to use for testing if a site is blocked

  • domain – URL string of domain to check for being blocked

  • retry_on – Argument to retry based on the returned value (wait <timeout> seconds for a given outcome)

  • timeout – Max time to retry for (default 30 seconds)

  • page_output – Optional path to write page content to