Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: user-guide: add list of :fn/* #605

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dgr marked this conversation as resolved.
Show resolved Hide resolved
* 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
dgr marked this conversation as resolved.
Show resolved Hide resolved
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
Loading