Skip to content

New function - Abort #41

@oliver-kriska

Description

@oliver-kriska

Hello,
I would like to ask you about implementation abort function so we can skip some resources to load, especially in my case images and videos.
I made this function here:
https://github.com/geometerio/playwright-elixir/blob/ab729b6f6f1f4f6d9e238d5e97598757b968c548/lib/playwright/route.ex#L14-L15

@spec abort(t(), binary()) :: :ok
  defp abort(%Route{session: session} = route, error_code \\ nil) do
    Channel.post(session, {:guid, route.guid}, :abort, %{error_ode: error_code})
  end

and implementation:

Playwright.Page.route(page_loader, "**/*", fn route, request ->
      if request.resource_type in ["image", "font"] do
        Playwright.Route.abort(route, "blockedbyclient")
      else
        Playwright.Route.continue(route)
      end
    end)

But it crash server, I very new in playwright so not sure where can be problem.

Doc for abort is here and my code is here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions