Packages

A webdriver bidi client written in Gleam, for Gleam.

Current section

Files

Jump to
butterbee src butterbee@commands@input.erl
Raw

src/butterbee@commands@input.erl

-module(butterbee@commands@input).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/butterbee/commands/input.gleam").
-export([perform_actions/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" ## [Input commands](https://w3c.github.io/webdriver-bidi/#module-input-commands)\n"
"\n"
" The input commands module contains commands found in the input section of the\n"
" webdriver bidi protocol. Butterbee uses these internally to create the high level\n"
" API. But you can use these commands directly if you want something specific.\n"
).
-file("src/butterbee/commands/input.gleam", 32).
?DOC(
" The input.performActions command performs a specified sequence of user input actions.\n"
" \n"
" ## Example\n"
"\n"
" ```gleam\n"
" let click_params =\n"
" perform_actions.default(context)\n"
" |> perform_actions.with_actions([\n"
" perform_actions.with_pointer_actions(\"mouse action\", [\n"
" perform_actions.pointer_down_action(mouse_button_to_int(key.LeftClick)),\n"
" perform_actions.pointer_up_action(mouse_button_to_int(key.LeftClick)),\n"
" ]),\n"
" ])\n"
" ```\n"
"\n"
" [w3c](https://w3c.github.io/webdriver-bidi/#command-input-performActions)\n"
).
-spec perform_actions(
butterbee@internal@socket:web_driver_socket(),
butterbidi@input@commands@perform_actions:perform_actions_parameters()
) -> {butterbee@internal@socket:web_driver_socket(),
{ok, butterbidi@definition:command_response()} |
{error, butterbee@internal@error:butterbee_error()}}.
perform_actions(Socket, Params) ->
Command = {input_command, perform_actions},
Request = butterbidi@definition:command_to_json(
{command,
butterbee@internal@id:from_unix(),
Command,
[{<<"params"/utf8>>,
butterbidi@input@commands@perform_actions:perform_actions_parameters_to_json(
Params
)}]}
),
Response = butterbee@internal@socket:send_request(Socket, Request, Command),
{Socket, Response}.