TestSelector.Test.FlokiHelpers.find_test_selectors

You're seeing just the function find_test_selectors, go back to TestSelector.Test.FlokiHelpers module for more information.
Link to this function

find_test_selectors(string, selector)

View Source

Specs

find_test_selectors(String.t() | Floki.html_tree(), String.t()) ::
  Floki.html_tree()

Returns a list of elements by a given test-selector inside a string or HTML tree.

It will raise with an error if a conn is supplied as first argument.

Examples

iex> text = ~S(<a test-selector="hello" test-value="world"></a><a test-selector="foo" test-value="bar"></a>)
iex> find_test_selectors(text, "hello")
[{"a", [{"test-selector", "hello"}, {"test-value", "world"}], []}]

iex> tree = [{"a", [{"test-selector", "hello"}, {"test-value", "world"}], []}, {"a", [{"test-selector", "foo"}, {"test-value", "bar"}], []}]
iex> find_test_selectors(tree, "foo")
[{"a", [{"test-selector", "foo"}, {"test-value", "bar"}], []}]

iex> text = ~S(<a test-selector="hello" test-value="world"></a>)
iex> find_test_selectors(text, "foo")
[]
Link to this function

find_test_selectors(input, selector, value)

View Source

Specs

find_test_selectors(String.t() | Floki.html_tree(), String.t(), String.t()) ::
  Floki.html_tree()

Returns a list of elements by a given test-selector and test-value inside a string or HTML tree.

It will raise with an error if a conn is supplied as first argument.

Examples

iex> text = ~S(<a test-selector="hello" test-value="world"></a><a test-selector="foo" test-value="bar"></a>)
iex> find_test_selectors(text, "hello", "world")
[{"a", [{"test-selector", "hello"}, {"test-value", "world"}], []}]

iex> tree = [{"a", [{"test-selector", "hello"}, {"test-value", "world"}], []}, {"a", [{"test-selector", "foo"}, {"test-value", "bar"}], []}]
iex> find_test_selectors(tree, "foo", "bar")
[{"a", [{"test-selector", "foo"}, {"test-value", "bar"}], []}]

iex> text = ~S(<a test-selector="hello" test-value="world"></a>)
iex> find_test_selectors(text, "hello", "bar")
[]