GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • playwright

This view

  • Original page
  • New address

GeezerVison is showing playwright.hexdocs.pm — Playwright — playwright v1.49.1-alpha.2

View Source Playwright (playwright v1.49.1-alpha.2)

Playwright launches and manages with Playwright browser-server instances.

An example of using Playwright to drive automation:

Example

alias Playwright.API.{Browser, Page, Response}

{:ok, browser}  = Playwright.launch(:chromium)
{:ok, page}     = Browser.new_page(browser)
{:ok, response} = Page.goto(browser, "http://example.com")

assert Response.ok(response)

Browser.close(browser)

Summary

Types

client()

The web client type used for launch and connect functions.

t()

%Playwright{}

Functions

connect(client, options \\ %{})

Initiates an instance of Playwright.Browser use the WebSocket transport.

init(owner, initializer)

Optional callback implementation for Playwright.SDK.ChannelOwner.init/2.

launch(client, options \\ %{})

Initiates an instance of Playwright.Browser use the Driver transport.

Types

Link to this type

client()

View Source
@type client() :: :chromium | :firefox | :webkit

The web client type used for launch and connect functions.

Link to this type

t()

View Source
@type t() :: %Playwright{
  chromium: term(),
  firefox: term(),
  guid: term(),
  initializer: term(),
  listeners: term(),
  parent: term(),
  session: term(),
  type: term(),
  webkit: term()
}

%Playwright{}

Functions

Link to this function

connect(client, options \\ %{})

View Source

Initiates an instance of Playwright.Browser use the WebSocket transport.

Note that this approach assumes the a Playwright Server is running and handling WebSocket requests at the configured ws_endpoint.

Returns

  • {:ok, Playwright.Browser.t()}

Arguments

key/nametypdescription
clientparamclient()The type of client (browser) to launch.
optionsparamoptions()Playwright.SDK.Config.connect_options()
Link to this function

init(owner, initializer)

View Source
@spec init(
  struct(),
  map()
) :: {atom(), struct()}

Optional callback implementation for Playwright.SDK.ChannelOwner.init/2.

If implemented, the callback will receive:

  1. The newly created "channel owner" struct.
  2. The :initializer received from the Playwright browser server.

The implementation has the option of "patching" the struct as stored in the catalog, and/or binding event handlers.

Example

def init(%{session: session} = owner, _initializer) do
  Channel.bind(session, {:guid, owner.guid}, :close, fn event ->
    Logger.warning("Closing #{inspect(event.target)}")
  end)

  {:ok, %{owner | version: "1.2.3"}}
end

Returns

  • {:ok, struct()}

Arguments

key/nametypedescription
ownerparamstruct()The newly created channel owner (resource).
initializerparamstruct()The initializer received from with the channel owner instance was derived.
Link to this function

launch(client, options \\ %{})

View Source
@spec launch(client(), Playwright.SDK.Config.connect_options() | map()) ::
  {:ok, Playwright.Browser.t()}
@spec launch(client(), Playwright.SDK.Config.launch_options() | map()) ::
  {:ok, Playwright.Browser.t()}

Initiates an instance of Playwright.Browser use the Driver transport.

Returns

  • {:ok, Playwright.Browser.t()}

Arguments

key/nametypdescription
clientparamclient()The type of client (browser) to launch.
optionsparamoptions()Playwright.SDK.Config.launch_options()
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.