PlaywrightEx.ElementHandle (PlaywrightEx v0.13.0)

Copy Markdown View Source

Interact with a Playwright ElementHandle.

There is no official channel documentation, since this is considered Playwright internal.

Reference: https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/client/elementHandle.ts

Summary

Functions

Releases this handle's browser reference. Already-closed targets are treated as successfully disposed; other errors are preserved.

Evaluates an expression on this element. A function receives the element and the optional :arg. Returns the deserialized value or the original protocol error.

Sets the files on the input element represented by this handle.

Types

dispose_opt()

@type dispose_opt() :: {:connection, GenServer.name()} | {:timeout, timeout()}

evaluate_opt()

@type evaluate_opt() ::
  {:connection, GenServer.name()}
  | {:timeout, timeout()}
  | {:expression, binary()}
  | {:is_function, boolean()}
  | {:arg, term()}

set_input_files_opt()

@type set_input_files_opt() ::
  {:connection, GenServer.name()}
  | {:timeout, timeout()}
  | {:local_paths, binary() | [binary()]}
  | {:payloads, PlaywrightEx.FilePayload.t() | [PlaywrightEx.FilePayload.t()]}

Functions

dispose(element_id, opts \\ [])

@spec dispose(PlaywrightEx.guid(), [dispose_opt()]) :: {:ok, any()} | {:error, any()}

Releases this handle's browser reference. Already-closed targets are treated as successfully disposed; other errors are preserved.

Options

  • :connection (term/0) - The Connection process name. Defaults to PlaywrightEx.Supervisor.Connection. The default value is PlaywrightEx.Supervisor.Connection.

  • :timeout (timeout/0) - Required. Operation timeout in milliseconds. 0 means no waiting; :infinity disables the timeout.

evaluate(element_id, opts \\ [])

@spec evaluate(PlaywrightEx.guid(), [evaluate_opt() | PlaywrightEx.unknown_opt()]) ::
  {:ok, any()} | {:error, any()}

Evaluates an expression on this element. A function receives the element and the optional :arg. Returns the deserialized value or the original protocol error.

Options

  • :connection (term/0) - The Connection process name. Defaults to PlaywrightEx.Supervisor.Connection. The default value is PlaywrightEx.Supervisor.Connection.

  • :timeout (timeout/0) - Required. Operation timeout in milliseconds. 0 means no waiting; :infinity disables the timeout.

  • :expression (String.t/0) - Required.

  • :is_function (boolean/0) - The default value is false.

  • :arg (term/0) - The default value is nil.

set_input_files(element_id, opts \\ [])

@spec set_input_files(PlaywrightEx.guid(), [
  set_input_files_opt() | PlaywrightEx.unknown_opt()
]) ::
  {:ok, any()} | {:error, any()}

Sets the files on the input element represented by this handle.

Pass either :local_paths or :payloads. An empty list clears the selected files. This operation can be used with the element handle carried by a subscribed page's :file_chooser event.

Reference: https://playwright.dev/docs/api/class-filechooser#file-chooser-set-files

Options

  • :connection (term/0) - The Connection process name. Defaults to PlaywrightEx.Supervisor.Connection. The default value is PlaywrightEx.Supervisor.Connection.

  • :timeout (timeout/0) - Required. Operation timeout in milliseconds. 0 means no waiting; :infinity disables the timeout.

  • :local_paths - A file path or list of file paths. Relative paths are resolved relative to the current working directory. An empty list clears the selected files.

  • :payloads (PlaywrightEx.FilePayload.t() | [PlaywrightEx.FilePayload.t()]) - An in-memory file payload or list of payloads. An empty list clears the selected files.