Playwright (playwright v0.1.17-preview-7) View Source
Playwright module provides functions to launch a Playwright.Browser.
The following is a typical example of using Playwright to drive automation.
Example
alias Playwright.{Browser, Page, Response}
browser = Playwright.launch(:chromium)
assert Browser.new_page(browser)
|> Page.goto("http://example.com")
|> Response.ok()
Browser.close(browser)
Link to this section Summary
Functions
Optional callback implementation for Playwright.ChannelOwner.init/2.
Launch an instance of Playwright.Browser.
Link to this section Types
Link to this section Functions
Specs
Optional callback implementation for Playwright.ChannelOwner.init/2.
If implemented, the callback will receive:
- The newly created "channel owner" struct.
- The
:initializerreceived 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.warn("Closing #{inspect(event.target)}")
end)
{:ok, %{owner | version: "1.2.3"}}
endReturns
{:ok, struct()}
Arguments
| key/name | type | description | |
|---|---|---|---|
owner | param | struct() | The newly created channel owner (resource). |
initializer | param | struct() | The initializer received from with the channel owner instance was derived. |
Specs
launch(client_type() | nil) :: Playwright.Browser.t()
Launch an instance of Playwright.Browser.
Arguments
type: The type of client (browser) to launch.(:chromium | nil)with default:chromium