gleewright/browser
Launching browsers and browser contexts.
You usually don’t need this module: the test runner in gleewright
launches a browser and gives every test a fresh page in its own context.
It is useful for scripting Playwright outside of a test run:
use browser <- step.try(browser.launch(browser.Chromium, headless: True, slow_mo: 0))
use context <- step.try(browser.new_context(
browser,
base_url: "",
viewport_width: 1280,
viewport_height: 720,
timeout: 10_000,
))
use page <- step.try(page.new(context))
use _ <- step.try(page.goto(page, "https://example.com"))
use _ <- step.try(page.screenshot(page, "example.png"))
browser.close(browser)
Types
Which browser engine to run tests in.
pub type BrowserType {
Chromium
Firefox
Webkit
}
Constructors
-
ChromiumChromium, the open source base of Chrome and Edge.
-
FirefoxFirefox.
-
WebkitWebKit, the engine behind Safari.
Values
pub fn browser_type_from_string(
name: String,
) -> Result(BrowserType, Nil)
Parse a browser name. Accepts "chromium", "chrome", "firefox",
"webkit" and "safari".
pub fn browser_type_to_string(
browser_type: BrowserType,
) -> String
The name Playwright uses for a browser type, e.g. "chromium".
pub fn launch(
browser_type: BrowserType,
headless headless: Bool,
slow_mo slow_mo: Int,
) -> step.Step(Browser)
Launch a browser.
pub fn new_context(
browser: Browser,
base_url base_url: String,
viewport_width width: Int,
viewport_height height: Int,
timeout timeout: Int,
) -> step.Step(Context)
Create a new isolated context. Relative URLs passed to page.goto are
resolved against base_url; pass "" for no base URL. timeout is the
default timeout in milliseconds for actions and navigations.