1.x does not evolve 0.16's API: it is a port of Playwright's JS client, so playwright.dev applies (the changelog's introduction has the model). Port each 0.x call by what it does: find the JS method for it, then its Elixir name with From playwright.dev to Elixir.
Dependency and names
{:playwright, "~> 1.65.0-rc.5", hex: :playwright_ex}The app is :playwright and the modules are Playwright.*: PlaywrightEx.Page is
Playwright.Page. A module of your own named Playwright (alias MyApp.Playwright) shadows
them: call yours in full or alias it as: MyPlaywright; below alias MyApp.Playwright in a
sorted alias list, write alias Elixir.Playwright.Page.
What replaces what
Unknown options raise everywhere in 1.x, where 0.16 passed them on.
- npm:
mix playwright.installinstalls the pinned driver and its browsers, no npmplaywrightpackage (Getting started). An npm CLI you keep withexecutable:must bePlaywright.Driver.version/0's version: nothing checks it. PlaywrightEx.Supervisor:Playwright.Supervisortakes:name,:executable,:node,:cache_dirand:env: notimeout:orjs_logger:, andws_endpoint:moves toPlaywright.BrowserType.connect/3. The driver options default toconfig :playwright, :driver(Playwright.Driver).PlaywrightEx.launch_browser/2:Playwright.instance() |> Playwright.chromium()andPlaywright.BrowserType.launch!/2;Playwright.firefox/1andPlaywright.webkit/1replace the browser type argument.- guids and
connection:: calls take the handles calls return (Browser,BrowserContext,Page,Frame,Locator).Playwright.BrowserContext.new_page/1returns the page: use its functions and locators rather than itsPlaywright.Page.main_frame/1. timeout:on every call: optional now, with defaults per context (Timeouts).Selector: a selector string, or better a locator such asPlaywright.Page.get_by_role/3.EventWaiter: start the wait before the action, withPlaywright.Page.expect_download!/3and the otherexpect_*functions, orPlaywright.Page.wait_for_event/3andPlaywright.Promise.await!/1(Events and waiting).Route,Download,Artifact,FilePayload:Playwright.RouteandPlaywright.Downloadare the JS classes (Network, Downloads); a download's artifact is internal, and a file payload is a map (File choosers).evaluate:Playwright.Page.evaluate/4takes the JS source and its argument, and notimeout:(evaluatetakes JS source,niland:null).- Screenshots:
Playwright.Page.screenshot/2returns the image's bytes, not base64. - JS logger and protocol subscriptions: listen to events, as in JS:
Playwright.BrowserContext.on/3with:consoleand:web_error,Playwright.Page.on/3with:request,:responseand:web_socket,Playwright.WebSocket.on/3with:frame_sentand:frame_received(Events and waiting). PlaywrightEx.send/2and the other raw-protocol functions: gone, as JS has no public equivalent. Call the method JS has, such asPlaywright.Page.set_viewport_size/2orPlaywright.Page.close/2.- Hand-rolled test setup:
use Playwright.Casegives each test apagefrom a pooled browser and closes it (Testing with ExUnit). PhoenixTest.Playwright users follow its docs instead.