Skip to content

Commit

Permalink
doc: user-guide: add list of :fn/*
Browse files Browse the repository at this point in the history
Added a complete list of :fn/* functions that are available in the map
syntax. This includes everything in impl/xpath.clj, including
:fn/has-string.
  • Loading branch information
dgr committed Jul 11, 2024
1 parent da66c37 commit f00ac0f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ A release with an intentional breaking changes is marked with:
(https://github.com/tupini07[@tupini07])
* https://github.com/clj-commons/etaoin/issues/566[#566]: Recognize `:driver-log-level` for Edge
* bump all deps to current versions
* https://github.com/clj-commons/etaoin/issues/602[#602]: Document all :fn/* query pseudo-functions in a definitive list
* tests
** https://github.com/clj-commons/etaoin/issues/572[#572]: stop using chrome `--no-sandbox` option, it has become problematic on Windows (and we did not need it anyway)
* docs
Expand Down
36 changes: 35 additions & 1 deletion doc/01-user-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,41 @@ Useful when you need to select a third row from a table, for example.
* Any non-special key represents an attribute and its value.
* `:fn/` is a prefix followed by a supported query function.

Examples:
There are several query functions of the form `:fn/*`. Each query
function takes a parameter which is the value associated with the
query function keyword in the map.

* `:fn/text`: Takes a string parameter. Matches if the
element has the exact text specified.
* `:fn/has-text`: Takes a string parameter. Matches if the
element includes the specified text.
* `:fn/has-string`: Takes a string parameter. Matches if the element
string contains the specified string. The difference between
`:fn/has-text` and `:fn/has-string` is the difference between the
XPath `text()` and `string()` functions (`text()` is the text within
a given element and `string()` is the text of all descendant
elements concatenated together in document order). Generally, if
you're targeting an element at the top of the hierarchy, you
probably want `:fn/has-string`, and if you're targeting a single
element at the bottom of the hierarchy, you probably want to use
`:fn/has-text`.
* `:fn/has-class`: Takes a string parameter. Matches if the element's
`class` attribute includes the string. Unlike using a `:class` key
in the map, `:fn/has-class` can match single classes, whereas
`:class` is an exact match of the whole class string.
* `:fn/has-classes`: Takes a vector of strings parameter. Matches if
the element's `class` attribute includes _all_ of the specified
class strings.
* `:fn/link`: Takes a string parameter. Matches if the element's
`href` attribute contains the specified string.
* `:fn/enabled`: Takes a boolean (`true` or `false`) parameter. If the
parameter is `true`, matches if the element is enabled. If the
parameter is `false`, matches if the element is disabled.
* `:fn/disabled`: Takes a boolean (`true` or `false`) parameter. If
the parameter is `true`, matches if the element is disabled. If the
parameter is `true`, matches if the element is enabled.

Here are some examples of the map syntax:

* find the first `div` tag
+
Expand Down

0 comments on commit f00ac0f

Please sign in to comment.