Skip to main content

BrowseTheWeb

The BrowseTheWeb class represents an actor's ability to interact with a browser using Playwright. This class provides methods for performing various browser actions.

Extends

This class extends the abstract Ability class from Core.

Methods

using

public static using(page: Page): BrowseTheWeb;
  • Description: Initializes the BrowseTheWeb ability by passing an already existing Playwright Page object.
  • Parameters:
    • page - The Playwright Page that will be used to browse.
  • Returns: BrowseTheWeb - Returns the ability to use a browser.

as

public static as(actor: Actor, alias?: string): BrowseTheWeb;
  • Description: Uses this ability as an actor.
  • Parameters:
    • actor - The actor using this ability.
    • alias - (Optional) The alias for the ability
  • Returns: UseAPI - The ability to use the BrowseTheWeb as the actor, optionally with an alias name.

getPage

public getPage(): Page;
  • Description: Gets the page object.
  • Returns: Page - The page object.

resolveSelectorToLocator

Introduced in: 1.4.0

public resolveSelectorToLocator(): Page;
  • Description: Resolves a given Selector to a Playwright Locator.
  • Parameters:
    • selector - The selector of the element.
    • options - (optional) Advanced selector lookup options.
    • frameTree - An array of frame selector(s).
  • Returns: Promise<Locator> - Returns resolved Locator(s) as per Playwright definition.

Methods inherited from Core Ability

withAlias

Introduced in core: 0.3.0

public withAlias(alias: string): Ability;
  • Description: Defines the ability's alias.
  • Parameters:
    • alias - The alias.
  • Returns: Ability - Returns the current ability.

Usage:

Actor.can(Ability.withAlias('aliased'));