View Source PlaywrightTest.Case (playwright v1.49.1-alpha.1)
Use PlaywrightTest.Case
in an ExUnit test module to start a Playwright server and put it into the test context.
Examples
defmodule Example.PageTest do
use PlaywrightTest.Case
describe "features w/ default context" do
test "goes to a page", %{page: page} do
text =
page
|> Playwright.Page.goto("https://playwright.dev")
|> Playwright.Page.text_content(".navbar__title")
assert text == "Playwright"
end
end
end
defmodule Example.BrowserTest do
use PlaywrightTest.Case
describe "features w/out `page` context" do
@tag exclude: [:page]
test "goes to a page", %{browser: browser} do
page =
browser
|> Playwright.Browser.new_page()
text =
page
|> Playwright.Page.goto("https://playwright.dev")
|> Playwright.Page.text_content(".navbar__title")
assert text == "Playwright"
# must close test-created `page`
Playwright.Page.close(page)
end
end
end