### Start Wallaby in test_helper.exs Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Ensures Wallaby is started in test_helper.exs. ```elixir {:ok, _} = Application.ensure_all_started(:wallaby) ``` -------------------------------- ### Wallaby.start_session Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Starts a new browser session with optional configuration. ```APIDOC ## [FUNCTION] Wallaby.start_session ### Description Starts a new browser session with optional configuration options. ### Method Function ### Endpoint Wallaby.start_session(options) ### Parameters #### Query Parameters - **window_size** (list) - Optional - Default window size as `[width: 1280, height: 720]`. ### Request Example ```elixir Wallaby.start_session(window_size: [width: 1280, height: 720]) ``` ### Response #### Success Response Returns a session. ``` -------------------------------- ### Query and action example with find and assert_has Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Shows how to use a query with actions: find all users, take the first, and assert it has the expected name. Demonstrates the pipe-based DSL. ```elixir session |> find(css(".user", count: 3)) |> List.first |> assert_has(css(".user-name", count: 1, text: "Ada")) ``` -------------------------------- ### HTML example for Wallaby queries Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Example HTML structure used to illustrate Wallaby queries and actions. It contains a list of users with class names and text content. ```html ``` -------------------------------- ### Resize and get window size Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Resizes the window during a test and retrieves the current window size. ```elixir resize_window(session, 100, 100) window_size(session) ``` -------------------------------- ### window_size Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Gets the current window size. ```APIDOC ## [ACTION] window_size ### Description Returns the current window size. ### Method Action ### Endpoint window_size(session) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. ### Request Example ```elixir window_size(session) ``` ### Response #### Success Response Returns a tuple `{width, height}`. ``` -------------------------------- ### Configure Wallaby driver (Chrome or Selenium) Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Configures the Wallaby driver. Chrome is the default; Selenium requires installing selenium and geckodriver or chromedriver. ```elixir # Chrome config :wallaby, driver: Wallaby.Chrome # default # Selenium config :wallaby, driver: Wallaby.Selenium ``` -------------------------------- ### Configure Wallaby for umbrella apps with Ecto sandbox Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Setup for testing an umbrella app with a Phoenix web app (MyWebApp) and a separate persistence app (MyPersistenceApp) using Ecto 2 or 3 with sandbox mode. Requires the SQL sandbox plug, test config, a Wallaby base_url, and phoenix_ecto as a test dependency. ```elixir # my_web_app/lib/endpoint.ex defmodule MyWebApp.Endpoint do use Phoenix.Endpoint, otp_app: :my_web_app if Application.compile_env(:my_persistence_app, :sandbox, false) do plug Phoenix.Ecto.SQL.Sandbox end ``` ```elixir # my_web_app/config/test.exs config :my_web_app, MyWebApp.Endpoint, server: true config :my_persistence_app, :sql_sandbox, true ``` ```elixir # my_web_app/test/test_helper.exs Application.put_env(:wallaby, :base_url, MyWebApp.Endpoint.url) ``` ```elixir # my_web_app/mix.exs def deps do [ {:phoenix_ecto, "~> 3.0", only: :test} ] end ``` -------------------------------- ### Write a Wallaby feature test with Wallaby.Feature Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Example of writing a Wallaby feature test using the Wallaby.Feature module. Uses ExUnit.Case with async: true and demonstrates visiting a page, finding elements, and asserting content. ```elixir defmodule YourApp.UserListTest do use ExUnit.Case, async: true use Wallaby.Feature feature "users have names", %{session: session} do session |> visit("/users") |> find(Query.css(".user", count: 3)) |> List.first() |> assert_has(Query.css(".user-name", text: "Chris")) end end ``` -------------------------------- ### Wallaby feature test for creating todos Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Example test for a simple Todo application using Wallaby.Feature. It runs concurrently with async: true and uses Wallaby.Query helpers to visit, fill in, click, and assert on page content. ```elixir defmodule MyApp.Features.TodoTest do use ExUnit.Case, async: true use Wallaby.Feature import Wallaby.Query, only: [css: 2, text_field: 1, button: 1] feature "users can create todos", %{session: session} do session |> visit("/todos") |> fill_in(text_field("New Todo"), with: "Write my first Wallaby test") |> click(button("Save")) |> assert_has(css(".alert", text: "You created a todo")) |> assert_has(css(".todo-list > .todo", text: "Write my first Wallaby test")) end end ``` -------------------------------- ### Wallaby feature test for multiple users Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Example test for multiple users interacting with a page simultaneously. Uses @sessions 2 to run two sessions and demonstrates sending messages between users. ```elixir defmodule MyApp.Features.MultipleUsersTest do use ExUnit.Case, async: true use Wallaby.Feature import Wallaby.Query, only: [text_field: 1, button: 1, css: 2] @page message_path(Endpoint, :index) @message_field text_field("Share Message") @share_button button("Share") def message(msg), do: css(".messages > .message", text: msg) @sessions 2 feature "That users can send messages to each other", %{sessions: [user1, user2]} do user1 |> visit(@page) |> fill_in(@message_field, with: "Hello there!") |> click(@share_button) user2 |> visit(@page) |> fill_in(@message_field, with: "Hello yourself") |> click(@share_button) user1 |> assert_has(message("Hello yourself")) user2 |> assert_has(message("Hello there!")) end end ``` -------------------------------- ### Add webpack asset compilation alias Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Adds a custom alias to recompile assets with webpack before tests. This method is less error prone but causes a delay when starting the test suite. ```elixir def project do [ app: :my_app, version: "1.0.0", aliases: aliases() ] end defp aliases, do: [ "test": [ "assets.compile --quiet", "ecto.create --quiet", "ecto.migrate", "test", ], "assets.compile": &compile_assets/1 ] defp compile_assets(_) do Mix.shell().cmd("cd assets && ./node_modules/.bin/webpack --mode development", quiet: true ) end ``` -------------------------------- ### Enable WebAuthn Virtual Authenticator in Chrome Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Enable the WebAuthn Virtual Authenticator in Chrome via Chromedriver. This makes Chrome automatically present a virtual Passkey when WebAuthn `create()` or `get()` APIs are called. Requires a Chrome session and the Chromedriver. ```elixir {:ok, _result} = Wallaby.HTTPClient.request(:post, "#{session.url}/chromium/send_command_and_get_result", %{ cmd: "WebAuthn.enable", params: %{} }) {:ok, result} = Wallaby.HTTPClient.request(:post, "#{session.url}/chromium/send_command_and_get_result", %{ cmd: "WebAuthn.addVirtualAuthenticator", params: %{ options: %{ protocol: "ctap2", transport: "internal", hasResidentKey: true, hasUserVerification: true, isUserVerified: true, automaticPresenceSimulation: true } } }) ``` -------------------------------- ### Accept prompt with user input using accept_prompt Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Handle a `window.prompt` dialog and emulate user input via the `:with` option. The function must trigger the prompt; the returned value is the prompt message. ```elixir prompt_message = accept_prompt session, [with: "User input"], fn(session) -> click(session, link("Trigger prompt")) end ``` -------------------------------- ### Set default window size with start_session Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Sets the default window size by passing the window_size option to Wallaby.start_session/1. ```elixir Wallaby.start_session(window_size: [width: 1280, height: 720]) ``` -------------------------------- ### visit Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Navigates to a specified URL or path. ```APIDOC ## [ACTION] visit ### Description Navigates the browser to a given URL or path. ### Method Action ### Endpoint visit(session, url) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **url** (string) - Required - The URL or path to navigate to. ### Request Example ```elixir visit(session, "/page.html") visit(session, user_path(Endpoint, :index, 17)) ``` ### Response #### Success Response Returns the session. ``` -------------------------------- ### Navigate with visit Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Navigates directly to a page using a path or a route helper. Shows two ways to call visit. ```elixir visit(session, "/page.html") visit(session, user_path(Endpoint, :index, 17)) ``` -------------------------------- ### Run Wallaby tests Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Commands to run Wallaby's test suite. Use mix test for unit tests, mix test.drivers for all drivers, WALLABY_DRIVER=chrome or selenium for a specific driver, and mix test.all for all tests. ```shell # Unit tests $ mix test # Integration tests for all drivers $ mix test.drivers # Integration tests for a specific driver $ WALLABY_DRIVER=chrome mix test $ WALLABY_DRIVER=selenium mix test # All tests $ mix test.all ``` -------------------------------- ### Accept JavaScript alert with accept_alert Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Handle a `window.alert` dialog. The function passed to `accept_alert/2` must trigger the dialog; the returned value is the alert message. ```elixir alert_message = accept_alert session, fn(session) -> click(session, link("Trigger alert")) end ``` -------------------------------- ### Chain find with callback and click Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Chains find with a callback that asserts the number of users, then clicks a link. The callback returns the parent element for further chaining. ```elixir page |> find(css(".users"), & assert has?(&1, css(".user", count: 3))) |> click(link("Next Page")) ``` -------------------------------- ### Customize screenshot directory Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Customizes the screenshot directory via configuration in config/test.exs or by setting the environment in test_helper.exs. ```elixir # config/test.exs config :wallaby, screenshot_dir: "/file/path" # test_helper.exs Application.put_env(:wallaby, :screenshot_dir, "/file/path") ``` -------------------------------- ### Find with callback to fill form Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Defines module attributes for queries and uses find with a callback to fill in a form and click save. The callback receives the found element and returns the parent. ```elixir @user_form css(".user-form") @name_field text_field("Name") @email_field text_field("Email") @save_button button("Save") find(page, @user_form, fn(form) -> form |> fill_in(@name_field, with: "Chris") |> fill_in(@email_field, with: "c@keathley.io") |> click(@save_button) end) ``` -------------------------------- ### Configure Wallaby otp_app Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Configures the otp_app when using Wallaby.Feature with Ecto. ```elixir config :wallaby, otp_app: :your_app ``` -------------------------------- ### Take screenshot with take_screenshot Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Takes a screenshot. Screenshots are saved to a 'screenshots' directory in the directory where tests were run. ```elixir take_screenshot(session) ``` -------------------------------- ### Form interactions with fill_in, clear, and click Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Shows various form interactions: filling in text fields, clearing a field, and clicking options, radio buttons, and buttons. ```elixir fill_in(session, text_field("First Name"), with: "Chris") clear(session, text_field("last_name")) click(session, option("Some option")) click(session, radio_button("My Fancy Radio Button")) click(session, button("Some Button")) ``` -------------------------------- ### Add SQL Sandbox plug to Phoenix endpoint Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Adds the Phoenix.Ecto.SQL.Sandbox plug at the top of the endpoint and ensures user_agent is in connect_info for concurrent testing. ```elixir # lib/your_app_web/endpoint.ex defmodule YourAppWeb.Endpoint do use Phoenix.Endpoint, otp_app: :your_app if Application.compile_env(:your_app, :sandbox, false) do plug Phoenix.Ecto.SQL.Sandbox end # ... socket("/live", Phoenix.LiveView.Socket, websocket: [connect_info: [:user_agent, session: @session_options]] ) ``` -------------------------------- ### Enable sandbox in test config Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Enables sandbox mode for concurrent testing. ```elixir # config/test.exs config :your_app, :sandbox, Ecto.Adapters.SQL.Sandbox ``` -------------------------------- ### Click a link with click and link Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Clicks a link identified by its text using the link query. ```elixir click(session, link("Page 1")) ``` -------------------------------- ### Set Wallaby base_url in test_helper.exs Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Sets the base_url so Wallaby can resolve relative paths. ```elixir # test/test_helper.exs Application.put_env(:wallaby, :base_url, YourAppWeb.Endpoint.url) ``` -------------------------------- ### Allow Ecto sandbox in LiveView with on_mount hook Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Required for testing Phoenix LiveView (as of version 0.17.7) with Wallaby. The hook allows the Ecto sandbox in LiveView mounts; include it in the router's live_session. ```elixir defmodule MyApp.Hooks.AllowEctoSandbox do import Phoenix.LiveView import Phoenix.Component def on_mount(:default, _params, _session, socket) do allow_ecto_sandbox(socket) {:cont, socket} end defp allow_ecto_sandbox(socket) do %{assigns: %{phoenix_ecto_sandbox: metadata}} = assign_new(socket, :phoenix_ecto_sandbox, fn -> if connected?(socket), do: get_connect_info(socket, :user_agent) end) Phoenix.Ecto.SQL.Sandbox.allow(metadata, Application.get_env(:your_app, :sandbox)) end end ``` ```elixir live_session :default, on_mount: MyApp.Hooks.AllowEctoSandbox do # ... end ``` -------------------------------- ### Define custom sandbox module Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Defines a custom sandbox module to share additional resources (e.g., Mox expectations) between test and browser processes. ```elixir # test/support/sandbox.ex defmodule YourApp.Sandbox do def allow(repo, owner_pid, child_pid) do # Delegate to the Ecto sandbox Ecto.Adapters.SQL.Sandbox.allow(repo, owner_pid, child_pid) # Add custom process-sharing configuration Mox.allow(MyMock, owner_pid, child_pid) end end ``` -------------------------------- ### take_screenshot Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Takes a screenshot of the current page. ```APIDOC ## [ACTION] take_screenshot ### Description Takes a screenshot of the current page and saves it to the screenshots directory. ### Method Action ### Endpoint take_screenshot(session) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. ### Request Example ```elixir take_screenshot(session) ``` ### Response #### Success Response Returns the session. ``` -------------------------------- ### Redirect JS logs to file with :js_logger Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Redirect JavaScript console logs to a file by setting the `:js_logger` config option to an IO device. Logging is disabled by setting `:js_logger` to `nil`. ```elixir {:ok, file} = File.open("browser_logs.log", [:write]) Application.put_env(:wallaby, :js_logger, file) ``` -------------------------------- ### Send keys with send_keys Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Sends a list of keys to the focused element, including special keys like :enter. ```elixir send_keys(session, ["Example", "Text", :enter]) ``` -------------------------------- ### css Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Query for elements using a CSS selector with optional count and text filters. ```APIDOC ## [QUERY] css ### Description Query for elements matching a CSS selector. Supports options like `count` and `text` to filter results. ### Method Query ### Endpoint css(selector, options) ### Parameters #### Query Parameters - **selector** (string) - Required - CSS selector to match elements. - **count** (integer) - Optional - Expected number of matching elements. - **text** (string) - Optional - Text content to filter elements. ### Request Example ```elixir css(".user", count: 3) css(".user-name", count: 1, text: "Ada") ``` ### Response #### Success Response Returns a query object that can be used with actions like `find`, `assert_has`, etc. ``` -------------------------------- ### Configure Wallaby hackney_options Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Configure Wallaby's hackney options in config.exs. The first block sets timeout and recv_timeout to :infinity, and the second overrides the timeout to 5_000 milliseconds. ```elixir config :wallaby, hackney_options: [timeout: :infinity, recv_timeout: :infinity] # Overriding a value config :wallaby, hackney_options: [timeout: 5_000] ``` -------------------------------- ### resize_window Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Resizes the browser window to the given dimensions. ```APIDOC ## [ACTION] resize_window ### Description Resizes the browser window to the specified width and height. ### Method Action ### Endpoint resize_window(session, width, height) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **width** (integer) - Required - The new window width. - **height** (integer) - Required - The new window height. ### Request Example ```elixir resize_window(session, 100, 100) ``` ### Response #### Success Response Returns the session. ``` -------------------------------- ### Add Wallaby dependency in mix.exs Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Adds Wallaby as a test-only dependency in mix.exs. Requires Elixir 1.17+ and OTP 26+. ```elixir def deps do [ {:wallaby, "~> 0.30", runtime: false, only: :test} ] end ``` -------------------------------- ### Chain assertions with actions Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Chains assertions and actions because assert_has and refute_has return the parent element. Demonstrates a typical test flow. ```elixir session |> assert_has(css(".signup-form")) |> fill_in(text_field("Email", with: "c@keathley.io")) |> click(button("Sign up")) |> refute_has(css(".error")) |> assert_has(css(".alert", text: "Welcome!")) ``` -------------------------------- ### fill_in Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Fills in a form field with a given value. ```APIDOC ## [ACTION] fill_in ### Description Fills in a form field with a specified value. ### Method Action ### Endpoint fill_in(session, query, with: value) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **query** (Query) - Required - The query for the form field. - **with** (string) - Required - The value to fill in. ### Request Example ```elixir fill_in(session, text_field("First Name"), with: "Chris") ``` ### Response #### Success Response Returns the session. ``` -------------------------------- ### send_keys Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Sends a sequence of keys to the active element. ```APIDOC ## [ACTION] send_keys ### Description Sends specific keys to the focused element. ### Method Action ### Endpoint send_keys(session, keys) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **keys** (list) - Required - List of keys to send, e.g., ["Example", "Text", :enter]. ### Request Example ```elixir send_keys(session, ["Example", "Text", :enter]) ``` ### Response #### Success Response Returns the session. ``` -------------------------------- ### find Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Finds elements matching a query, optionally scoping actions within the found element. ```APIDOC ## [ACTION] find ### Description Finds an element or list of elements matching a query. Can accept a callback to scope actions within the found element. ### Method Action ### Endpoint find(session, query, callback \\ nil) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **query** (Query) - Required - The query to find elements. - **callback** (function) - Optional - A function that receives the found element and returns the parent. ### Request Example ```elixir find(page, @user_form, fn(form) -> form |> fill_in(@name_field, with: "Chris") |> fill_in(@email_field, with: "c@keathley.io") |> click(@save_button) end) ``` ### Response #### Success Response Returns the found element(s) or the parent if a callback is provided. ``` -------------------------------- ### Scope actions with find without callback Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Uses find without a callback to scope subsequent actions within the found element. Demonstrates filling in fields and clicking a button. ```elixir page |> find(css(".user-form")) |> fill_in(text_field("Name"), with: "Chris") |> fill_in(text_field("Email"), with: "c@keathley.io") |> click(button("Save")) ``` -------------------------------- ### Use custom sandbox in test config Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Updates the test config to use the custom sandbox module. ```elixir # config/test.exs config :your_app, :sandbox, YourApp.Sandbox ``` -------------------------------- ### Assertions with assert_has, refute_has, and has? Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Shows custom assertions: assert_has checks presence, refute_has checks absence, and has? checks presence with a visibility option. ```elixir assert_has(session, css(".signup-form")) refute_has(session, css(".alert")) has?(session, css(".user-edit-modal", visible: false)) ``` -------------------------------- ### Enable automatic screenshots on failure Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Enables automatic screenshots on failure when using the Wallaby.Feature.feature/3 macro. Configured in config/test.exs or test_helper.exs. ```elixir # config/test.exs config :wallaby, screenshot_on_failure: true # test_helper.exs Application.put_env(:wallaby, :screenshot_on_failure, true) ``` -------------------------------- ### Enable Phoenix endpoint in test config Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Enables Phoenix to serve endpoints in tests. ```elixir # config/test.exs config :your_app, YourAppWeb.Endpoint, server: true ``` -------------------------------- ### Block on async DOM with assert_has Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Use Wallaby's blocking queries to wait for asynchronous DOM updates. The `assert_has` call blocks until the `.async-result` element appears, avoiding manual timeouts and race conditions. ```elixir session |> click(button("Some Async Button")) |> assert_has(css(".async-result")) |> click(button("Next Action")) ``` -------------------------------- ### click Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Clicks on an element identified by a query. ```APIDOC ## [ACTION] click ### Description Clicks on an element, such as a link, button, option, or radio button. ### Method Action ### Endpoint click(session, query) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **query** (Query) - Required - The query for the element to click. ### Request Example ```elixir click(session, link("Page 1")) click(session, option("Some option")) click(session, radio_button("My Fancy Radio Button")) click(session, button("Some Button")) ``` ### Response #### Success Response Returns the session. ``` -------------------------------- ### refute_has Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Asserts that an element does not exist and returns the parent for chaining. ```APIDOC ## [ACTION] refute_has ### Description Asserts that an element matching the query does not exist. Returns the parent element for chaining. ### Method Action ### Endpoint refute_has(session, query) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **query** (Query) - Required - The query to assert non-existence. ### Request Example ```elixir refute_has(session, css(".alert")) ``` ### Response #### Success Response Returns the parent element. ``` -------------------------------- ### assert_has Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Asserts that an element exists and returns the parent for chaining. ```APIDOC ## [ACTION] assert_has ### Description Asserts that an element matching the query exists. Returns the parent element for chaining. ### Method Action ### Endpoint assert_has(session, query) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **query** (Query) - Required - The query to assert existence. ### Request Example ```elixir assert_has(session, css(".signup-form")) ``` ### Response #### Success Response Returns the parent element. ``` -------------------------------- ### has? Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Checks if an element exists and returns a boolean. ```APIDOC ## [ACTION] has? ### Description Checks if an element matching the query exists. Returns a boolean. ### Method Action ### Endpoint has?(session, query) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **query** (Query) - Required - The query to check existence. ### Request Example ```elixir has?(session, css(".user-edit-modal", visible: false)) ``` ### Response #### Success Response Returns `true` if the element exists, `false` otherwise. ``` -------------------------------- ### Add esbuild to test alias Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Adds esbuild default to the test alias so assets are recompiled before tests. ```elixir defp aliases do [ "test": [ "esbuild default", "ecto.create --quiet", "ecto.migrate", "test", ] ] end ``` -------------------------------- ### clear Source: https://github.com/elixir-wallaby/wallaby/blob/main/README.md Clears the contents of a form field. ```APIDOC ## [ACTION] clear ### Description Clears the contents of a form field. ### Method Action ### Endpoint clear(session, query) ### Parameters #### Path Parameters - **session** (Session) - Required - The browser session. #### Query Parameters - **query** (Query) - Required - The query for the form field. ### Request Example ```elixir clear(session, text_field("last_name")) ``` ### Response #### Success Response Returns the session. ```