From 7b271a8b0bef49ed582bb1606e242f66043ad3a8 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Thu, 24 Aug 2023 15:15:28 +0200 Subject: [PATCH] Add name_of/1 html helper Currently with Floki there's no way to query for `[name=foo[some]]` selector --- test/support/html.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/support/html.ex b/test/support/html.ex index 4623eb7b1..9c59cdcf9 100644 --- a/test/support/html.ex +++ b/test/support/html.ex @@ -37,4 +37,8 @@ defmodule Plausible.Test.Support.HTML do |> Floki.text() |> String.trim() end + + def name_of(element) do + List.first(Floki.attribute(element, "name")) + end end