A wrapper over the W3C WebDriver Specification to automate popular browsers.
Tries to normalize differences across the various implementations.
See the User Guide for details and examples.
This is a rich API:
WebDriver
with-driver
boot-driver
defaults
defaults-global
when-not-drivers
with-chrome
with-chrome-headless
chrome
chrome-headless
chrome?
when-chrome
when-not-chrome
with-edge
with-edge-headless
edge
edge-headless
when-edge
when-not-edge
with-firefox
with-firefox-headless
firefox
firefox-headless
firefox?
when-firefox
when-not-firefox
with-safari
safari
safari?
when-safari
when-not-safari
driver?
driver-type
running?
headless?
when-headless
when-not-headless
disconnect-driver
stop-driver
quit
WebDriver Lower Level Comms
Driver Sessions
Querying/Selecting DOM Elements
query
query-all
query-tree
query-from
query-all-from
get-active-element
query-from-shadow-root
query-from-shadow-root-el
query-all-from-shadow-root
query-all-from-shadow-root-el
has-shadow-root?
has-shadow-root-el?
exists?
absent?
displayed?
displayed-el?
enabled?
enabled-el?
disabled?
invisible?
visible?
child
children
get-element-tag
get-element-tag-el
get-element-attr
get-element-attr-el
get-element-attrs
get-element-property
get-element-property-el
get-element-properties
has-class?
has-class-el?
has-no-class?
get-element-css
get-element-css-el
get-element-csss
get-element-shadow-root
get-element-shadow-root-el
get-element-text
get-element-text-el
has-text?
get-element-inner-html
get-element-inner-html-el
get-element-value
get-element-value-el
get-element-rect
get-element-rect-el
get-element-size
get-element-size-el
get-element-location
get-element-location-el
get-element-box
intersects?
use-css
with-css
use-xpath
with-xpath
Browser Navigation
Mouse/Pointer
click
click-el
click-single
click-multi
left-click-on
middle-click-on
right-click-on
mouse-click-on
double-click
double-click-el
drag-and-drop
touch-tap
Inputs/Forms
fill
fill-active
fill-el
fill-multi
fill-human
fill-human-active
fill-human-el
fill-human-multi
select
selected?
selected-el?
upload-file
remote-file
disabled?
enabled?
clear
clear-el
submit
Cookies
Alerts
Scrolling
get-scroll
scroll
scroll-by
scroll-bottom
scroll-top
scroll-down
scroll-up
scroll-left
scroll-right
scroll-offset
scroll-query
Scripting
Browser Windows
get-window-handle
get-window-handles
get-window-rect
set-window-rect
get-window-position
set-window-position
get-window-size
set-window-size
maximize
switch-window
switch-window-next
new-window
close-window
Frames
Page Info
Screenshots
Print to PDF
Browser Info
Waiting
doto-wait
wait
with-wait
*wait-interval*
*wait-timeout*
with-wait-interval
with-wait-timeout
wait-exists
wait-absent
wait-visible
wait-invisible
wait-disabled
wait-enabled
wait-has-alert
wait-has-class
wait-has-text
wait-has-text-everywhere
wait-predicate
wait-running
Browser Timeouts
get-timeouts
set-timeouts
get-implicit-timeout
set-implicit-timeout
get-page-load-timeout
set-page-load-timeout
get-script-timeout
set-script-timeout
with-script-timeout
WebDriver Actions
make-action-input
make-key-input
make-mouse-input
make-pen-input
make-pointer-input
make-touch-input
add-action
add-double-pause
add-key-down
add-key-press
add-key-up
with-key-down
add-pause
add-pointer-click
add-pointer-click-el
add-pointer-double-click
add-pointer-double-click-el
add-pointer-down
add-pointer-up
with-pointer-btn-down
with-pointer-left-btn-down
add-pointer-move
add-pointer-move-to-el
add-pointer-cancel
perform-actions
release-actions
Convenience
A wrapper over the [W3C WebDriver Specification](https://www.w3.org/TR/webdriver/) to automate popular browsers. Tries to normalize differences across the various implementations. See the [User Guide](/doc/01-user-guide.adoc) for details and examples. This is a rich API: **WebDriver** - [[with-driver]] [[boot-driver]] [[defaults]] [[defaults-global]] [[when-not-drivers]] - [[with-chrome]] [[with-chrome-headless]] [[chrome]] [[chrome-headless]] [[chrome?]] [[when-chrome]] [[when-not-chrome]] - [[with-edge]] [[with-edge-headless]] [[edge]] [[edge-headless]] [[when-edge]] [[when-not-edge]] - [[with-firefox]] [[with-firefox-headless]] [[firefox]] [[firefox-headless]] [[firefox?]] [[when-firefox]] [[when-not-firefox]] - [[with-safari]] [[safari]] [[safari?]] [[when-safari]] [[when-not-safari]] - [[driver?]] [[driver-type]] [[running?]] - [[headless?]] [[when-headless]] [[when-not-headless]] - [[disconnect-driver]] [[stop-driver]] [[quit]] **WebDriver Lower Level Comms** - [[execute]] [[with-http-error]] **Driver Sessions** - [[get-status]] [[create-session]] [[delete-session]] **Querying/Selecting DOM Elements** - [[query]] [[query-all]] [[query-tree]] [[query-from]] [[query-all-from]] - [[get-active-element]] - [[query-from-shadow-root]] [[query-from-shadow-root-el]] [[query-all-from-shadow-root]] [[query-all-from-shadow-root-el]] - [[has-shadow-root?]] [[has-shadow-root-el?]] - [[exists?]] [[absent?]] - [[displayed?]] [[displayed-el?]] [[enabled?]] [[enabled-el?]] [[disabled?]] [[invisible?]] [[visible?]] - [[child]] [[children]] - [[get-element-tag]] [[get-element-tag-el]] - [[get-element-attr]] [[get-element-attr-el]] [[get-element-attrs]] - [[get-element-property]] [[get-element-property-el]] [[get-element-properties]] - [[has-class?]] [[has-class-el?]] [[has-no-class?]] - [[get-element-css]] [[get-element-css-el]] [[get-element-csss]] - [[get-element-shadow-root]] [[get-element-shadow-root-el]] - [[get-element-text]] [[get-element-text-el]] [[has-text?]] - [[get-element-inner-html]] [[get-element-inner-html-el]] - [[get-element-value]] [[get-element-value-el]] - [[get-element-rect]] [[get-element-rect-el]] [[get-element-size]] [[get-element-size-el]] [[get-element-location]] [[get-element-location-el]] [[get-element-box]] [[intersects?]] - [[use-css]] [[with-css]] [[use-xpath]] [[with-xpath]] **Browser Navigation** - [[go]] [[get-url]] [[get-hash]] [[set-hash]] - [[back]] [[forward]] - [[refresh]] [[reload]] **Mouse/Pointer** - [[click]] [[click-el]] [[click-single]] [[click-multi]] - [[left-click-on]] [[middle-click-on]] [[right-click-on]] [[mouse-click-on]] - [[double-click]] [[double-click-el]] - [[drag-and-drop]] - [[touch-tap]] **Inputs/Forms** - [[fill]] [[fill-active]] [[fill-el]] [[fill-multi]] - [[fill-human]] [[fill-human-active]] [[fill-human-el]] [[fill-human-multi]] - [[select]] [[selected?]] [[selected-el?]] - [[upload-file]] [[remote-file]] - [[disabled?]] [[enabled?]] - [[clear]] [[clear-el]] - [[submit]] **Cookies** - [[get-cookie]] [[get-cookies]] - [[set-cookie]] - [[delete-cookie]] [[delete-cookies]] **Alerts** - [[has-alert?]] [[has-no-alert?]] - [[get-alert-text]] - [[accept-alert]] [[dismiss-alert]] **Scrolling** - [[get-scroll]] - [[scroll]] [[scroll-by]] - [[scroll-bottom]] [[scroll-top]] - [[scroll-down]] [[scroll-up]] [[scroll-left]] [[scroll-right]] - [[scroll-offset]] - [[scroll-query]] **Scripting** - [[js-execute]] [[js-async]] [[js-localstorage-clear]] [[el->ref]] [[add-script]] **Browser Windows** - [[get-window-handle]] [[get-window-handles]] - [[get-window-rect]] [[set-window-rect]] - [[get-window-position]] [[set-window-position]] - [[get-window-size]] [[set-window-size]] - [[maximize]] - [[switch-window]] [[switch-window-next]] - [[new-window]] [[close-window]] **Frames** - [[switch-frame]] [[switch-frame-first]] [[switch-frame-parent]] [[switch-frame-top]] [[with-frame]] **Page Info** - [[get-source]] [[get-title]] **Screenshots** - [[screenshot]] [[screenshot-element]] [[with-screenshots]] **Print to PDF** - [[print-page]] **Browser Info** - [[supports-logs?]] [[get-log-types]] [[get-logs]] - [[get-user-agent]] - [[with-postmortem]] **Waiting** - [[doto-wait]] [[wait]] [[with-wait]] - [[*wait-interval*]] [[*wait-timeout*]] [[with-wait-interval]] [[with-wait-timeout]] - [[wait-exists]] [[wait-absent]] - [[wait-visible]] [[wait-invisible]] - [[wait-disabled]] [[wait-enabled]] - [[wait-has-alert]] - [[wait-has-class]] - [[wait-has-text]] [[wait-has-text-everywhere]] - [[wait-predicate]] - [[wait-running]] **Browser Timeouts** - [[get-timeouts]] [[set-timeouts]] - [[get-implicit-timeout]] [[set-implicit-timeout]] - [[get-page-load-timeout]] [[set-page-load-timeout]] - [[get-script-timeout]] [[set-script-timeout]] [[with-script-timeout]] **WebDriver Actions** - [[make-action-input]] [[make-key-input]] [[make-mouse-input]] [[make-pen-input]] [[make-pointer-input]] [[make-touch-input]] - [[add-action]] - [[add-double-pause]] - [[add-key-down]] [[add-key-press]] [[add-key-up]] [[with-key-down]] - [[add-pause]] - [[add-pointer-click]] [[add-pointer-click-el]] [[add-pointer-double-click]] [[add-pointer-double-click-el]] - [[add-pointer-down]] [[add-pointer-up]] - [[with-pointer-btn-down]] [[with-pointer-left-btn-down]] - [[add-pointer-move]] [[add-pointer-move-to-el]] - [[add-pointer-cancel]] - [[perform-actions]] [[release-actions]] **Convenience** - [[rand-uuid]]
Frequency in seconds to check if we should still wait, default for wait-*
functions.
Frequency in seconds to check if we should still wait, default for `wait-*` functions.
Maximum seconds to wait, default for wait-*
functions.
Maximum seconds to wait, default for `wait-*` functions.
(absent? driver q & more)
Opposite of exists?
.
Opposite of [[exists?]].
(accept-alert driver)
Have driver
accept open alert dialog.
Have `driver` accept open alert dialog. https://www.w3.org/TR/webdriver2/#dfn-accept-alert
(add-action input action)
Return input
with action
added.
Return `input` with `action` added.
(add-double-pause input & [duration])
Return input
source with two pause actions added.
Optionally specify a duration
, defaults to 0.
Return `input` source with two pause actions added. Optionally specify a `duration`, defaults to 0.
(add-key-down input key)
Return input
source with key
down action added.
Return `input` source with `key` down action added.
(add-key-press input key)
Return input
source with key
down and up actions added.
Return `input` source with `key` down and up actions added.
(add-key-up input key)
Return input
source with key
up action added.
Return `input` source with `key` up action added.
(add-pause input & [duration])
Return input
source with a pause action added.
Optionally specify a duration
, defaults to 0.
Return `input` source with a pause action added. Optionally specify a `duration`, defaults to 0.
(add-pointer-cancel input)
Return input
with a pointer cancel action added.
Return `input` with a pointer cancel action added.
(add-pointer-click input & [pointer-button])
Return input
source with pointer-button
down and up actions added.
pointer-button
defaults to etaoin.keys/mouse-left
Return `input` source with `pointer-button` down and up actions added. `pointer-button` defaults to [[etaoin.keys/mouse-left]]
(add-pointer-click-el input el & [pointer-button])
Return input
source with pointer-button
down and up actions on element el
added.
pointer-button
defaults to etaoin.keys/mouse-left
Return `input` source with `pointer-button` down and up actions on element `el` added. `pointer-button` defaults to [[etaoin.keys/mouse-left]]
(add-pointer-double-click input & [pointer-button])
Return input
source with pointer-button
down, up, down, up actions added.
pointer-button
defaults to etaoin.keys/mouse-left
Return `input` source with `pointer-button` down, up, down, up actions added. `pointer-button` defaults to [[etaoin.keys/mouse-left]]
(add-pointer-double-click-el input el & [pointer-button])
Return input
source with pointer-button
down, up, down, up actions on element el
added.
pointer-button
defaults to etaoin.keys/mouse-left
Return `input` source with `pointer-button` down, up, down, up actions on element `el` added. `pointer-button` defaults to [[etaoin.keys/mouse-left]]
(add-pointer-down input & [pointer-button])
Return input
source with pointer-button
down action added.
button
defaults to etaoin.keys/mouse-left
Return `input` source with `pointer-button` down action added. `button` defaults to [[etaoin.keys/mouse-left]]
(add-pointer-move input & [{:keys [x y origin duration]}])
Return input
source with pointer move action added.
Moves the pointer from origin
to offset x
y
with optional duration
in milliseconds.
Possible origin
values are:
"viewport"
move to x
y
offset in viewport. This is the default."pointer"
x
y
are interpreted as offsets from the current pointer location.el->ref
:
(el->ref (query driver q))
where q
is query
to find the element.
Optionally specify :duration
in milliseconds, defaults to 250.
Return `input` source with pointer move action added. Moves the pointer from `origin` to offset `x` `y` with optional `duration` in milliseconds. Possible `origin` values are: - `"viewport"` move to `x` `y` offset in viewport. This is the default. - `"pointer"` `x` `y` are interpreted as offsets from the current pointer location. - a map that represents a web element for example via [[el->ref]]: ```Clojure (el->ref (query driver q)) ``` where `q` is [[query]] to find the element. Optionally specify `:duration` in milliseconds, defaults to 250.
(add-pointer-move-to-el input el & [{:keys [duration]}])
Return input
source with pointer move to element el
action added.
Optionally specify :duration
in milliseconds, defaults to 250.
Return `input` source with pointer move to element `el` action added. Optionally specify `:duration` in milliseconds, defaults to 250.
(add-pointer-up input & [pointer-button])
Return input
source with pointer-button
up action added.
button
defaults to etaoin.keys/mouse-left
Return `input` source with `pointer-button` up action added. `button` defaults to [[etaoin.keys/mouse-left]]
(add-script driver url)
Have driver
add script with src url
to page.
Have `driver` add script with src `url` to page.
(back driver)
Have driver
navigate backward in the browser history.
Have `driver` navigate backward in the browser history. https://www.w3.org/TR/webdriver2/#dfn-back
(boot-driver type)
(boot-driver type {:keys [host webdriver-url] :as opts})
Launch and return a driver of type
(e.g. :chrome
, :firefox
:safari
:edge
)
with opts
options.
:host
or :webdriver-url
is specified)Defaults taken from defaults-global
then defaults
for type
:
:port
- if :host
not specified, port is randomly generated for local WebDriver process
:capabilities
- are deep merged as part of connect logic.
opts
map is optionally, see Driver Options.
Launch and return a driver of `type` (e.g. `:chrome`, `:firefox` `:safari` `:edge`) with `opts` options. - creates a driver - launches a WebDriver process (or connects to an existing running process if `:host` or `:webdriver-url` is specified) - creates a session for driver Defaults taken from [[defaults-global]] then [[defaults]] for `type`: `:port` - if `:host` not specified, port is randomly generated for local WebDriver process `:capabilities` - are deep merged as part of connect logic. `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(child driver ancestor-el q)
Uses driver
to return single element satisfying query q
under given ancestor-el
element.
See query
for details on q
.
NOTE: child
has been deprecated in favor of query-from
which
more closely supports query
's syntax for q
and has a name which
better matches its functionality and the latest W3C WebDriver spec.
https://www.w3.org/TR/webdriver2/#dfn-find-element-from-element
Uses `driver` to return single element satisfying query `q` under given `ancestor-el` element. See [[query]] for details on `q`. NOTE: `child` has been deprecated in favor of `query-from` which more closely supports `query`'s syntax for `q` and has a name which better matches its functionality and the latest W3C WebDriver spec. https://www.w3.org/TR/webdriver2/#dfn-find-element-from-element
(children driver ancestor-el q)
Use driver
to return a vector of unique elements satisfying query q
under given ancestor-el
element.
See query
for details on q
.
NOTE: children
has been deprecated in favor of query-all-from
which
more closely supports query
's syntax for q
and has a name which
better matches its functionality and the latest W3C WebDriver spec.
https://www.w3.org/TR/webdriver2/#find-elements-from-element
Use `driver` to return a vector of unique elements satisfying query `q` under given `ancestor-el` element. See [[query]] for details on `q`. NOTE: `children` has been deprecated in favor of `query-all-from` which more closely supports `query`'s syntax for `q` and has a name which better matches its functionality and the latest W3C WebDriver spec. https://www.w3.org/TR/webdriver2/#find-elements-from-element
(chrome)
(chrome opts)
Launch and return a Chrome driver.
opts
map is optionally, see Driver Options.
Launch and return a Chrome driver. `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(chrome-headless)
(chrome-headless opt)
Launch and return a headless Chrome driver.
opts
map is optionally, see Driver Options.
Launch and return a headless Chrome driver. `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(chrome? driver)
Returns true if a driver
is Chrome.
Returns true if a `driver` is Chrome.
(clear driver q & more-qs)
Have driver
clear input element found by q
(and optionally more-qs
).
See query
for details on q
.
Have `driver` clear input element found by `q` (and optionally `more-qs`). See [[query]] for details on `q`.
(clear-el driver el)
Have driver
clear input element el
Have `driver` clear input element `el` https://www.w3.org/TR/webdriver2/#dfn-element-clear
(click driver q)
Have driver
click on element found by query q
.
See query
for details on q
.
Have `driver` click on element found by query `q`. See [[query]] for details on `q`. https://www.w3.org/TR/webdriver2/#dfn-element-click
(click-el driver el)
Have driver
click on element el
.
Have `driver` click on element `el`.
(click-multi driver qs & [pause])
Have driver
click on first element found by each query in vector qs
.
qs
a vector of queries [query1 query2 query3 ...]
pause
a pause prior to each click in seconds, default is 0
.See query
for details on q
s.
Have `driver` click on first element found by each query in vector `qs`. - `qs` a vector of queries `[query1 query2 query3 ...]` - `pause` a pause prior to each click in seconds, default is `0`. See [[query]] for details on `q`s.
(click-single driver q)
Have driver
click on element found by query q
.
If q
returns more than one element, throws.
See query
for details on q
.
Have `driver` click on element found by query `q`. If `q` returns more than one element, throws. See [[query]] for details on `q`.
(click-visible driver q & [opts])
Waits until driver
finds visible element via query q
then clicks on it.
opts
: see wait-predicate
opts.Waits until `driver` finds visible element via query `q` then clicks on it. - `opts`: see [[wait-predicate]] opts.
(close-window driver)
Have driver
close current browser window.
On last window close, closes the session.
See also: delete-session
,quit
Have `driver` close current browser window. On last window close, closes the session. See also: [[delete-session]],[[quit]] https://www.w3.org/TR/webdriver2/#dfn-close-window
(create-session driver & [capabilities])
Have driver
create a new session and return resulting session-id string.
Opens a browser window as a side-effect (visible if not running headless). Further requests to this driver will be for this session. Etaoin assumes one active session per driver.
Have `driver` create a new session and return resulting session-id string. Opens a browser window as a side-effect (visible if not running headless). Further requests to this driver will be for this session. Etaoin assumes one active session per driver. https://www.w3.org/TR/webdriver2/#dfn-new-sessions
WebDriver driver type specific option defaults. Note that for locally launched WebDriver processes the default port is a random free port.
WebDriver driver type specific option defaults. Note that for locally launched WebDriver processes the default port is a random free port.
WebDriver global option defaults
WebDriver global option defaults
(delete-cookie driver cookie-name)
Have driver
delete cookie with cookie cookie-name
.
Have `driver` delete cookie with cookie `cookie-name`. https://www.w3.org/TR/webdriver2/#dfn-delete-cookie
(delete-cookies driver)
Have driver
delete all browser cookies for all domains.
Have `driver` delete all browser cookies for all domains. https://www.w3.org/TR/webdriver2/#dfn-delete-all-cookies
(delete-session driver)
Have driver
delete the active session.
Closes the browser window.
See also: quit
, [[closed-window]].
Have `driver` delete the active session. Closes the browser window. See also: [[quit]], [[closed-window]]. https://www.w3.org/TR/webdriver2/#dfn-delete-session
(disconnect-driver driver)
Returns new driver
after disconnecting from a running WebDriver process.
Closes the current session that is stored in the driver if it still exists.
Removes the session from driver
.
Returns new `driver` after disconnecting from a running WebDriver process. Closes the current session that is stored in the driver if it still exists. Removes the session from `driver`.
(dismiss-alert driver)
Have driver
cancel open alert dialog.
Have `driver` cancel open alert dialog. https://www.w3.org/TR/webdriver2/#dfn-dismiss-alert
(displayed-el? driver el)
Return true if driver
finds el
is displayed/visible.
Displayed-ness is not part of w3c WebDriver spec and is vendor specific. https://www.w3.org/TR/webdriver2/#element-displayedness
See query
for details on q
.
Note: Safari webdriver has not implemented displayed
, for it
we currently default to some naive CSS display/visibilty checks.
Return true if `driver` finds `el` is displayed/visible. Displayed-ness is not part of w3c WebDriver spec and is vendor specific. https://www.w3.org/TR/webdriver2/#element-displayedness See [[query]] for details on `q`. Note: Safari webdriver has not implemented `displayed`, for it we currently default to some naive CSS display/visibilty checks.
(displayed? driver q)
Return true if element found by driver
with query q
is effectively displayed.
Displayed-ness is not part of w3c WebDriver spec and is vendor specific. https://www.w3.org/TR/webdriver2/#element-displayedness
Return true if element found by `driver` with query `q` is effectively displayed. Displayed-ness is not part of w3c WebDriver spec and is vendor specific. https://www.w3.org/TR/webdriver2/#element-displayedness
(doto-wait seconds obj & body)
The same as clojure.core/doto
but prepends each form with (wait
seconds
) clause.
The same as `clojure.core/doto` but prepends each form with ([[wait]] `seconds`) clause.
(double-click driver q)
Have driver
double-click on element found by query q
.
See query
for details on q
.
Have `driver` double-click on element found by query `q`. See [[query]] for details on `q`.
(double-click-el driver el)
Have driver
double-click on element el
.
Have `driver` double-click on element `el`.
(drag-and-drop driver q-from q-to)
Have driver
perform a drag and drop from element found by q-from
to element found by q-to
:
q-from
query;q-to
query;See query
for details on q-from
, q-to
.
Have `driver` perform a drag and drop from element found by `q-from` to element found by `q-to`: 1. moves mouse pointer to an element found with `q-from` query; 2. holds down the mouse button; 3. moves mouse to an element found with `q-to` query; 4. releases the mouse button. See [[query]] for details on `q-from`, `q-to`.
(driver-type driver)
Returns the type of driver (e.g., :chrome
, :firefox
, :safari
, or :edge
).
Returns the type of driver (e.g., `:chrome`, `:firefox`, `:safari`, or `:edge`).
(driver? driver type)
Return true if driver
is of type
(e.g. one of: :chrome
, :edge
, :firefox
, :safari
)
Return true if `driver` is of `type` (e.g. one of: `:chrome`, `:edge`, `:firefox`, `:safari`)
(edge)
(edge opts)
Launch and return an Edge driver.
opts
map is optionally, see Driver Options.
Launch and return an Edge driver. `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(edge-headless)
(edge-headless opts)
Launch and return a headless Edge driver.
opt
map is optionally, see Driver Options.
Launch and return a headless Edge driver. `opt` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(edge? driver)
Returns true if a driver
is Edge.
Returns true if a `driver` is Edge.
(el->ref el)
Return map representing an element reference for WebDriver.
The magic web-element-identifier
constant in the source is
taken from the WebDriver Spec.
Passing the element reference map to js-execute
automatically
expands it into a DOM node. For example:
;; returns UUID string for the element
(def el (query driver :button-ok))
;; the first argument will the an Element instance.
(js-execute driver "arguments[0].scrollIntoView()", (el->ref el))
Return map representing an element reference for WebDriver. The magic `web-element-identifier` constant in the source is taken from the [WebDriver Spec](https://www.w3.org/TR/webdriver2/#elements). Passing the element reference map to `js-execute` automatically expands it into a DOM node. For example: ```Clojure ;; returns UUID string for the element (def el (query driver :button-ok)) ;; the first argument will the an Element instance. (js-execute driver "arguments[0].scrollIntoView()", (el->ref el)) ```
(enabled-el? driver el)
Return true if driver
determines element el
is enabled.
For use on form elements.
Return true if `driver` determines element `el` is enabled. For use on form elements. https://www.w3.org/TR/webdriver2/#dfn-is-element-enabled
(enabled? driver q)
Returns true if driver
determines element found by query q
is enabled.
See query
for details on q
.
For use on form elements.
Returns true if `driver` determines element found by query `q` is enabled. See [[query]] for details on `q`. For use on form elements.
(execute {:keys [driver method path data]})
Return response from having :driver
execute HTTP :method
request to :path
with body :data
.
Response body automatically converted from JSON to a clojure keywordized map. Any HTTP status failure code results in a throw.
:method
HTTP method, e.g. :get
, :post
, :delete
, etc.:path
a vector of strings/keywords representing a server's path. For example:
[:session "aaaa-bbbb-cccc" :element "dddd-eeee" :find]
"/session/aaaa-bbbb-cccc/element/dddd-eeee/find"
.:data
optional body to send. Automatically converted to JSON.This can be useful to call when you want to invoke some WebDriver implementation specific feature that Etaoin has not otherwise exposed.
For example, if Etaoin did not already have get-url
:
(def driver (e/firefox))
(e/go driver "https://clojure.org")
(e/execute {:driver driver
:method :get
:path [:session (:session driver) :url]})
;; => {:value "https://clojure.org/"}
Return response from having `:driver` execute HTTP `:method` request to `:path` with body `:data`. Response body automatically converted from JSON to a clojure keywordized map. Any HTTP status failure code results in a throw. - `:method` HTTP method, e.g. `:get`, `:post`, `:delete`, etc. - `:path` a vector of strings/keywords representing a server's path. For example: - this: `[:session "aaaa-bbbb-cccc" :element "dddd-eeee" :find]` - becomes: `"/session/aaaa-bbbb-cccc/element/dddd-eeee/find"`. - `:data` optional body to send. Automatically converted to JSON. This can be useful to call when you want to invoke some WebDriver implementation specific feature that Etaoin has not otherwise exposed. For example, if Etaoin did not already have [[get-url]]: ```Clojure (def driver (e/firefox)) (e/go driver "https://clojure.org") (e/execute {:driver driver :method :get :path [:session (:session driver) :url]}) ;; => {:value "https://clojure.org/"} ```
(exists? driver q & more)
Return true if driver
can find element via query q
.
See query
for details on q
.
Keep in mind this does not validate whether the found element is visible, clickable and so on.
Return true if `driver` can find element via query `q`. See [[query]] for details on `q`. Keep in mind this does not validate whether the found element is visible, clickable and so on.
(fill driver q text & more)
Have driver
fill input element found by q
with text
(and optionally more
text).
See query
for details on q
.
Example:
(fill driver :simple-input "foo" "baz" 1)
;; fills the input with text: foobaz1
Have `driver` fill input element found by `q` with `text` (and optionally `more` text). See [[query]] for details on `q`. Example: ```Clojure (fill driver :simple-input "foo" "baz" 1) ;; fills the input with text: foobaz1 ```
(fill-active driver text & more)
Have driver
fill active element with text
(and optionally more
text).
Have `driver` fill active element with `text` (and optionally `more` text).
(fill-el driver el text & more)
Have driver
fill input element el
with text
(and optionally more
text).
Have `driver` fill input element `el` with `text` (and optionally `more` text). https://www.w3.org/TR/webdriver2/#dfn-element-send-keys
(fill-human driver q text)
(fill-human driver q text opts)
Have driver
fill element found by q
with text
as if it were a real human using opts
.
See query
for details on q
.
See fill-human-el
for details on opts
.
Have `driver` fill element found by `q` with `text` as if it were a real human using `opts`. See [[query]] for details on `q`. See [[fill-human-el]] for details on `opts`.
(fill-human-active driver text)
(fill-human-active driver text opts)
Fills the currently active element with text
as if it were a real
human using opts
. This is a simple convience function wrapped
around get-active-element
and fill-human-el
.
See fill-human-el
for details on opts
.
Fills the currently active element with `text` as if it were a real human using `opts`. This is a simple convience function wrapped around `get-active-element` and `fill-human-el`. See [[fill-human-el]] for details on `opts`.
(fill-human-el driver el text opts)
Have driver
fill element el
with text
as if it were a real human using opts
.
opts
:mistake-prob
probability of making a typo (0 to 1.0) (default: 0.1
):pause-max
maximum amount of time in seconds to pause between keystrokes (can be fractional) (default: 0.2
)Have `driver` fill element `el` with `text` as if it were a real human using `opts`. `opts` - `:mistake-prob` probability of making a typo (0 to 1.0) (default: `0.1`) - `:pause-max` maximum amount of time in seconds to pause between keystrokes (can be fractional) (default: `0.2`)
(fill-human-multi driver q-text)
(fill-human-multi driver q-text opts)
Have driver
fill multiple elements as if it were a real human being via q-text
using opts
.
q-text
can be:
{q1 "text1" q2 "text2" ...}
. There are no guarantees
about the order in which fields are filled.[q1 "text1" q2 "text2" ...]
. The fields are filled
in the order the fields are listed in the vector.See query
for details on q
s.
See fill-human-el
for details on opts
.
Have `driver` fill multiple elements as if it were a real human being via `q-text` using `opts`. `q-text` can be: - a map of `{q1 "text1" q2 "text2" ...}`. There are no guarantees about the order in which fields are filled. - a vector of `[q1 "text1" q2 "text2" ...]`. The fields are filled in the order the fields are listed in the vector. See [[query]] for details on `q`s. See [[fill-human-el]] for details on `opts`.
(fill-multi driver q-text)
Have driver
fill multiple inputs via q-text
.
q-text
can be:
{q1 "text1" q2 "text2" ...}
. There are no guarantees
about the order in which fields are filled.[q1 "text1" q2 "text2" ...]
. The fields are filled
in the order the fields are listed in the vector.See query
for details on q
s.
Have `driver` fill multiple inputs via `q-text`. `q-text` can be: - a map of `{q1 "text1" q2 "text2" ...}`. There are no guarantees about the order in which fields are filled. - a vector of `[q1 "text1" q2 "text2" ...]`. The fields are filled in the order the fields are listed in the vector. See [[query]] for details on `q`s.
(firefox)
(firefox opts)
Launch and return a Firefox driver.
opts
map is optionally, see Driver Options.
Launch and return a Firefox driver. `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(firefox-headless)
(firefox-headless opts)
Launch and return a headless Firefox driver.
opts
map is optionally, see Driver Options.
Launch and return a headless Firefox driver. `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(firefox? driver)
Returns true if a driver
is Firefox.
Returns true if a `driver` is Firefox.
(forward driver)
Have driver
navigate forward in the browser's history.
Have `driver` navigate forward in the browser's history. https://www.w3.org/TR/webdriver2/#dfn-forward
(get-active-element driver)
Have driver
return the active element on the page.
An active element is the one with the current focus.
It was selected for example by mouse click, a keyboard (tab, arrows), or autofocus
.
Have `driver` return the active element on the page. An active element is the one with the current focus. It was selected for example by mouse click, a keyboard (tab, arrows), or `autofocus`. https://www.w3.org/TR/webdriver2/#dfn-get-active-element
(get-alert-text driver)
Have driver
return text string from alert dialog (if present).
Have `driver` return text string from alert dialog (if present). https://www.w3.org/TR/webdriver2/#dfn-get-alert-text
(get-cookie driver cookie-name)
Have driver
return first cookie matching cookie-name
.
When cookie-name
is a keyword it will be converted appropriately.
Have `driver` return first cookie matching `cookie-name`. When `cookie-name` is a keyword it will be converted appropriately.
(get-cookies driver)
Have driver
return a vector of current browser cookies.
Each cookie is a map with structure:
{:name "cookie1",
:value "test1",
:path "/",
:domain "",
:expiry nil,
:secure false,
:httpOnly false}
Have `driver` return a vector of current browser cookies. Each cookie is a map with structure: ```Clojure {:name "cookie1", :value "test1", :path "/", :domain "", :expiry nil, :secure false, :httpOnly false} ``` https://www.w3.org/TR/webdriver2/#dfn-get-all-cookies
(get-element-attr driver q attribute)
Have driver
return value for attribute
of element found by q
.
Found attribute value is returned as string.
When element is found but attribute is absent, returns nil
.
See query
for details on q
.
Note: there is no special treatment of the class
attribute.
A single string with spaces is returned.
Example:
(def driver (firefox))
(get-element-attr driver {:tag :a} :class)
;; => "link link__external link__button"
Have `driver` return value for `attribute` of element found by `q`. Found attribute value is returned as string. When element is found but attribute is absent, returns `nil`. See [[query]] for details on `q`. Note: there is no special treatment of the `class` attribute. A single string with spaces is returned. Example: ```Clojure (def driver (firefox)) (get-element-attr driver {:tag :a} :class) ;; => "link link__external link__button" ```
(get-element-attr-el driver el attribute)
Have driver
return value for attribute
of element el
, or nil
if attribute does not exist.
Have `driver` return value for `attribute` of element `el`, or `nil` if attribute does not exist. https://www.w3.org/TR/webdriver2/#dfn-get-element-attribute
(get-element-attrs driver q & attributes)
Have driver
return values for attributes
of element found by query q
.
Found attribute values are returned as strings.
When element is found but attribute is absent, result is included in vector as nil
.
See query
for details on q
.
Have `driver` return values for `attributes` of element found by query `q`. Found attribute values are returned as strings. When element is found but attribute is absent, result is included in vector as `nil`. See [[query]] for details on `q`.
(get-element-box driver q)
Have driver
return map describing a bounding box for element found by query q
.
See query
for details on q
.
The result is a map with the following keys:
:x1
: top left x
coordinate;:y1
: top left y
coordinate;:x2
: bottom right x
coordinate;:y2
: bottom right y
coordinate;:width
: width as a difference b/w :x2
and :x1
;:height
: height as a difference b/w :y2
and :y1
.Have `driver` return map describing a bounding box for element found by query `q`. See [[query]] for details on `q`. The result is a map with the following keys: - `:x1`: top left `x` coordinate; - `:y1`: top left `y` coordinate; - `:x2`: bottom right `x` coordinate; - `:y2`: bottom right `y` coordinate; - `:width`: width as a difference b/w `:x2` and `:x1`; - `:height`: height as a difference b/w `:y2` and `:y1`.
(get-element-css driver q property)
Have driver
return the CSS style property
of element found by query q
.
property
is a string/keyword representing a CSS name.
Examples: :font
or "background-color"
The property will be returned if it was defined for the element itself or inherited.
Found property value is returned as string.
When element is found but property is absent, returns nil
.
See query
for details on q
.
Note: colors, fonts and some other properties may be represented differently for different browsers.
Example:
(def driver (firefox))
(e/go driver "https://clojars.org")
(get-element-css driver {:id :content} :background-color)
;; => "rgb(226, 228, 227)"
Have `driver` return the CSS style `property` of element found by query `q`. `property` is a string/keyword representing a CSS name. Examples: `:font` or `"background-color"` The property will be returned if it was defined for the element itself or inherited. Found property value is returned as string. When element is found but property is absent, returns `nil`. See [[query]] for details on `q`. Note: colors, fonts and some other properties may be represented differently for different browsers. Example: ```Clojure (def driver (firefox)) (e/go driver "https://clojars.org") (get-element-css driver {:id :content} :background-color) ;; => "rgb(226, 228, 227)" ```
(get-element-css-el driver el property)
Have driver
return value for CSS style property
of element el
, or nil
if property does not exist.
Have `driver` return value for CSS style `property` of element `el`, or `nil` if property does not exist. https://www.w3.org/TR/webdriver2/#dfn-get-element-css-value
(get-element-csss driver q & properties)
Have driver
return CSS style properties matching properties
of element found by query q
.
See query
for details on q
.
Found property values are returned as strings.
When element is found but property is absent, result is included in vector as nil
.
Note: colors, fonts and some other properties may be represented differently for different browsers.
Example:
(def driver (firefox))
(e/go driver "https://clojars.org")
(e/get-element-csss driver {:tag :body} :background-color :typo :line-height :font-size)
;; => ["rgb(226, 228, 227)" nil "20px" "14px"]
Have `driver` return CSS style properties matching `properties` of element found by query `q`. See [[query]] for details on `q`. Found property values are returned as strings. When element is found but property is absent, result is included in vector as `nil`. Note: colors, fonts and some other properties may be represented differently for different browsers. Example: ```Clojure (def driver (firefox)) (e/go driver "https://clojars.org") (e/get-element-csss driver {:tag :body} :background-color :typo :line-height :font-size) ;; => ["rgb(226, 228, 227)" nil "20px" "14px"] ```
(get-element-inner-html driver q)
Have driver
return inner text of element found by query q
.
See query
for details on q
.
For element with my-id
in <div id="my-id"><p class="foo">hello</p></div>
return will be
"<p class="foo">hello</p>"
.
See also: get-element-property
Have `driver` return inner text of element found by query `q`. See [[query]] for details on `q`. For element with `my-id` in `<div id="my-id"><p class="foo">hello</p></div>` return will be `"<p class="foo">hello</p>"`. See also: [[get-element-property]]
(get-element-inner-html-el driver el)
Have driver
return inner text of element el
.
For element with my-id
in <div id="my-id"><p class="foo">hello</p></div>
return will be
"<p class="foo">hello</p>"
.
See also: get-element-property-el
Have `driver` return inner text of element `el`. For element with `my-id` in `<div id="my-id"><p class="foo">hello</p></div>` return will be `"<p class="foo">hello</p>"`. See also: [[get-element-property-el]]
(get-element-location driver q)
Have driver
return map of :x
:y
offset, in pixels of element found by query q
.
See query
for details on q
.
Consider also: get-element-rect
Have `driver` return map of `:x` `:y` offset, in pixels of element found by query `q`. See [[query]] for details on `q`. Consider also: [[get-element-rect]]
(get-element-location-el driver el)
Have driver
return map of :x
:y
offset, in pixels of element el
.
Consider also: get-element-rect-el
Have `driver` return map of `:x` `:y` offset, in pixels of element `el`. Consider also: [[get-element-rect-el]]
(get-element-properties driver q & properties)
Have driver
return a vector of property values matching properties
of element found by query q
.
Found property values are returned as strings.
When element is found but property is absent, result is included in vector as nil
.
See also: get-element-property
See query
for details on q
.
Have `driver` return a vector of property values matching `properties` of element found by query `q`. Found property values are returned as strings. When element is found but property is absent, result is included in vector as `nil`. See also: [[get-element-property]] See [[query]] for details on `q`.
(get-element-property driver q property)
Have driver
value for property
of element found by query q
.
-property
examples: :innerHTML
, :outerHTML
, etc
Found property value is returned as string.
When element is found but property is absent, returns nil
.
See query
for details on q
.
Have `driver` value for `property` of element found by query `q`. -`property` examples: `:innerHTML`, `:outerHTML`, etc Found property value is returned as string. When element is found but property is absent, returns `nil`. See [[query]] for details on `q`.
(get-element-property-el driver el property)
Have driver
return value for property
of element el
.
-property
examples: :innerHTML
, :outerHTML
, etc
Have `driver` return value for `property` of element `el`. -`property` examples: `:innerHTML`, `:outerHTML`, etc https://www.w3.org/TR/webdriver2/#dfn-get-element-property
(get-element-rect driver q)
Have driver
return map of :width
, :height
, :x
and :y
, in pixels, of element found by query q
.
See query
for details on q
.
Have `driver` return map of `:width`, `:height`, `:x` and `:y`, in pixels, of element found by query `q`. See [[query]] for details on `q`.
(get-element-rect-el driver el)
Have driver
return map of :width
, :height
, :x
and :y
, in pixels, of element el
.
Have `driver` return map of `:width`, `:height`, `:x` and `:y`, in pixels, of element `el`. https://www.w3.org/TR/webdriver2/#dfn-get-element-rect
(get-element-shadow-root driver q)
Returns the shadow root for the first element matching the query, or
nil
if the element does not have a shadow root.
See query
for more details on q
.
Returns the shadow root for the first element matching the query, or `nil` if the element does not have a shadow root. See [[query]] for more details on `q`.
(get-element-shadow-root-el driver el)
Returns the shadow root for the specified element or nil
if the
element does not have a shadow root.
Returns the shadow root for the specified element or `nil` if the element does not have a shadow root.
(get-element-size driver q)
Have driver
return map of :width
and :height
, in pixels, of element found by query q
.
See query
for details on q
.
Consider also: get-element-rect
Have `driver` return map of `:width` and `:height`, in pixels, of element found by query `q`. See [[query]] for details on `q`. Consider also: [[get-element-rect]]
(get-element-size-el driver el)
Have driver
return map of :width
and :height
, in pixels, of element el
.
Consider also: get-element-rect-el
Have `driver` return map of `:width` and `:height`, in pixels, of element `el`. Consider also: [[get-element-rect-el]]
(get-element-tag driver q)
Have driver
return tag name of element found by query q
.
See query
for details on q
.
Have `driver` return tag name of element found by query `q`. See [[query]] for details on `q`.
(get-element-tag-el driver el)
Have driver
return tag name of element el
.
Have `driver` return tag name of element `el`. https://www.w3.org/TR/webdriver2/#dfn-get-element-tag-name
(get-element-text driver q)
Have driver
return inner text of element found by query q
.
See query
for details on q
.
Text return for <p class="foo">hello</p>
is "hello"
.
Have `driver` return inner text of element found by query `q`. See [[query]] for details on `q`. Text return for `<p class="foo">hello</p>` is `"hello"`.
(get-element-text-el driver el)
Have driver
return text of element el
.
Text return for <p class="foo">hello</p>
is "hello"
.
Have `driver` return text of element `el`. Text return for `<p class="foo">hello</p>` is `"hello"`. https://www.w3.org/TR/webdriver2/#dfn-get-element-text
(get-element-value driver q)
Have driver
return the value of element found by query q
.
To be used on input elements.
See query
for details on q
.
Have `driver` return the value of element found by query `q`. To be used on input elements. See [[query]] for details on `q`.
(get-element-value-el driver el)
Have driver
return the value of element el
.
To be used on input elements.
Have `driver` return the value of element `el`. To be used on input elements.
(get-hash driver)
Have driver
fetch the current hash fragment for the current page (nil when not set).
Example:
(def driver (chrome))
(go driver "https://en.wikipedia.org/wiki/Clojure")
(get-hash driver)
;; => nil
(go driver "https://en.wikipedia.org/wiki/Clojure#Popularity")
(get-hash driver)
;; => "Popularity"
See also: set-hash
.
Have `driver` fetch the current hash fragment for the current page (nil when not set). Example: ```Clojure (def driver (chrome)) (go driver "https://en.wikipedia.org/wiki/Clojure") (get-hash driver) ;; => nil (go driver "https://en.wikipedia.org/wiki/Clojure#Popularity") (get-hash driver) ;; => "Popularity" ```` See also: [[set-hash]].
(get-implicit-timeout driver)
Returns driver
timeout in seconds
for finding elements on the page.
Returns `driver` timeout in `seconds` for finding elements on the page.
(get-log-types driver)
Have driver
return a vector of log types the browser supports.
Chrome/Edge specific extension
Have `driver` return a vector of log types the browser supports. Chrome/Edge specific extension
(get-logs driver)
(get-logs driver logtype)
Have driver
return Javascript console log entries.
Each log entry is a map with the following structure:
{:level :warning,
:message "1,2,3,4 anonymous (:1)",
:timestamp 1511449388366,
:source nil,
:datetime #inst "2017-11-23T15:03:08.366-00:00"}
Supported by Chrome only:
:console-api
for :source
field.Chrome/Edge specific extension.
Have `driver` return Javascript console log entries. Each log entry is a map with the following structure: ```Clojure {:level :warning, :message "1,2,3,4 anonymous (:1)", :timestamp 1511449388366, :source nil, :datetime #inst "2017-11-23T15:03:08.366-00:00"} ``` Supported by Chrome only: - Returns all recorded logs. - Clears the logs once they have been read. - JS console logs have `:console-api` for `:source` field. - Entries about errors will have SEVERE level. Chrome/Edge specific extension.
(get-page-load-timeout driver)
Returns driver
timeout in seconds
for loading a page.
Returns `driver` timeout in `seconds` for loading a page.
(get-script-timeout driver)
Returns driver
timeout in seconds
for executing JavaScript.
Returns `driver` timeout in `seconds` for executing JavaScript.
(get-scroll driver)
Have driver
return the current scroll position as a map of :x
:y
.
Have `driver` return the current scroll position as a map of `:x` `:y`.
(get-source driver)
Have driver
return browser's current page HTML markup as a string.
Have `driver` return browser's current page HTML markup as a string. https://www.w3.org/TR/webdriver2/#dfn-get-page-source
(get-status driver)
Returns driver
status.
Can indicate readiness to create a new session.
The return varies for different driver implementations.
Returns `driver` status. Can indicate readiness to create a new session. The return varies for different driver implementations. https://www.w3.org/TR/webdriver2/#dfn-status
(get-timeouts driver)
Get millisecond
timeouts for :script
:pageLoad
implicit
.
Get `millisecond` timeouts for `:script` `:pageLoad` `implicit`. https://www.w3.org/TR/webdriver2/#dfn-get-timeouts
(get-title driver)
Have driver
return the current page title.
Have `driver` return the current page title. https://www.w3.org/TR/webdriver2/#dfn-get-title
(get-url driver)
Have driver
return the current url location as a string.
Have `driver` return the current url location as a string. https://www.w3.org/TR/webdriver2/#dfn-get-current-url
(get-user-agent driver)
Have driver
return the browser User-Agent
Have `driver` return the browser `User-Agent`
(get-window-handle driver)
Have driver
return the current browser window handle string.
Have `driver` return the current browser window handle string. https://www.w3.org/TR/webdriver2/#dfn-get-window-handle
(get-window-handles driver)
Have driver
return a vector of all browser window handle strings.
Have `driver` return a vector of all browser window handle strings. https://www.w3.org/TR/webdriver2/#dfn-get-window-handles
(get-window-position driver)
Have driver
return the current window position, in pixels relative to the screen, as a map of
:x
and :y
.
Consider also: get-window-rect
Have `driver` return the current window position, in pixels relative to the screen, as a map of `:x` and `:y`. Consider also: [[get-window-rect]]
(get-window-rect driver)
Have driver
return the current browser window rect as map of :x
, :y
, :width
, :height
Have `driver` return the current browser window rect as map of `:x`, `:y`, `:width`, `:height` https://www.w3.org/TR/webdriver2/#dfn-get-window-rect
(get-window-size driver)
Have driver
return the current browser window size in pixels as a map of :width
and :height
.
Consider also: get-window-rect
Have `driver` return the current browser window size in pixels as a map of `:width` and `:height`. Consider also: [[get-window-rect]]
(go driver url)
Have driver
open url
in the current browser window.
Example:
(def ff (firefox))
(go ff "http://google.com")
Have `driver` open `url` in the current browser window. Example: ```Clojure (def ff (firefox)) (go ff "http://google.com") ``` https://www.w3.org/TR/webdriver2/#dfn-navigate-to
(has-alert? driver)
Returns true if driver
sees an open alert dialog.
Returns true if `driver` sees an open alert dialog.
(has-class-el? driver el class)
Returns true if driver
finds that element el
includes class
in its class attribute.
Returns true if `driver` finds that element `el` includes `class` in its class attribute.
(has-class? driver q class)
Returns true if driver
finds that element found by query q
includes class
in its class attribute.
See query
for details on q
.
Returns true if `driver` finds that element found by query `q` includes `class` in its class attribute. See [[query]] for details on `q`.
(has-no-alert? driver)
Opposite of has-alert?
.
Opposite of [[has-alert?]].
(has-no-class? query q class)
Opposite of has-class?
.
Opposite of [[has-class?]].
(has-shadow-root-el? driver el)
Returns true
if the specified element has a shadow root or false
otherwise.
Returns `true` if the specified element has a shadow root or `false` otherwise.
(has-shadow-root? driver q)
Returns true
if the first element matching the query has a shadow
root or false
otherwise.
Returns `true` if the first element matching the query has a shadow root or `false` otherwise.
(has-text? driver text)
(has-text? driver q text)
Return true if driver
finds that text
appears anywhere on a page.
When q
is specified, restricts search inside the element that matches query q
.
See query
for details on q
.
Return true if `driver` finds that `text` appears anywhere on a page. When `q` is specified, restricts search inside the element that matches query `q`. See [[query]] for details on `q`.
(headless? driver)
Returns true if a driver
is in headless mode (without UI window).
Returns true if a `driver` is in headless mode (without UI window).
(intersects? driver q1 q2)
Return true if bounding boxes found by driver
for element found by query q1
intersects element found by query q2
.
Compares bounding boxes of found elements.
Return true if bounding boxes found by `driver` for element found by query `q1` intersects element found by query `q2`. Compares bounding boxes of found elements.
(js-async driver script & args)
Return result of driver
executing JavaScript script
with args
asynchornously in the browser.
Executes an asynchronous script in the browser and returns the result.
An asynchronous script one that typically performs some kind of IO operation,
like an AJAX request to the server. You cannot just use the return
statement
like you do in synchronous scripts.
The driver passes a special handler as the last argument that should be called to return the final result.
Note: calling this function requires the script
timeout to be set properly,
meaning non-zero positive value. See get-script-timeout
, set-script-timeout
and with-script-timeout
.
args
: additional arguments for your code. Automatically converted to JSON.Example of a script:
// the `arguments` would be an array of something like:
// [1, 2, true, ..., <special callback added by driver>]
var callback = arguments[arguments.length-1];
// so the main script would look like:
$.ajax({url: '/some/url', success: function(result) {
if (isResultOk(result)) {
callback({ok: getProgressData(result)});
}
else {
callback({error: getErrorData(result)});
}
}});
Return result of `driver` executing JavaScript `script` with `args` asynchornously in the browser. Executes an asynchronous script in the browser and returns the result. An asynchronous script one that typically performs some kind of IO operation, like an AJAX request to the server. You cannot just use the `return` statement like you do in synchronous scripts. The driver passes a special handler as the last argument that should be called to return the final result. *Note:* calling this function requires the `script` timeout to be set properly, meaning non-zero positive value. See [[get-script-timeout]], [[set-script-timeout]] and [[with-script-timeout]]. - `args`: additional arguments for your code. Automatically converted to JSON. Example of a script: ```Clojure // the `arguments` would be an array of something like: // [1, 2, true, ..., <special callback added by driver>] var callback = arguments[arguments.length-1]; // so the main script would look like: $.ajax({url: '/some/url', success: function(result) { if (isResultOk(result)) { callback({ok: getProgressData(result)}); } else { callback({error: getErrorData(result)}); } }}); ``` https://www.w3.org/TR/webdriver2/#dfn-execute-async-script
(js-execute driver script & args)
Return result of driver
executing Javascript script
with args
synchronously in the browser.
The script is sent as a string (can be multi-line). Under the hood,
the browser wraps your code into a function, so avoid using the function
clause at the top level.
Don't forget to add return <something>
operator if you are
interested in a resulting value.
You may access arguments through the built-in arguments
pseudo-array from your code. You may pass any data structures that
are JSON-compatible (scalars, maps, vectors).
The result value is also returned trough JSON encode/decode pipeline (JS objects turn to Clojure maps, arrays into vectors and so on).
args
: additional arguments for your script. Automatically converted to JSON.Example:
(def driver (chrome))
(js-execute driver "return arguments[0] + 1;" 42)
;; => 43
Return result of `driver` executing Javascript `script` with `args` synchronously in the browser. The script is sent as a string (can be multi-line). Under the hood, the browser wraps your code into a function, so avoid using the `function` clause at the top level. Don't forget to add `return <something>` operator if you are interested in a resulting value. You may access arguments through the built-in `arguments` pseudo-array from your code. You may pass any data structures that are JSON-compatible (scalars, maps, vectors). The result value is also returned trough JSON encode/decode pipeline (JS objects turn to Clojure maps, arrays into vectors and so on). - `args`: additional arguments for your script. Automatically converted to JSON. Example: ```Clojure (def driver (chrome)) (js-execute driver "return arguments[0] + 1;" 42) ;; => 43 ``` https://www.w3.org/TR/webdriver2/#dfn-execute-script
(js-localstorage-clear driver)
Have driver
clear local storage.
Have `driver` clear local storage.
(left-click-on driver q)
Have driver
move mouse pointer to element found by q
then click left mouse button.
See query
for details on q
.
Have `driver` move mouse pointer to element found by `q` then click left mouse button. See [[query]] for details on `q`.
(make-action-input type)
Return a new action input source of type
.
Return a new action input source of `type`.
(make-key-input)
Return a new action key input source.
Return a new action key input source.
(make-mouse-input)
Return a new action mouse input source.
Return a new action mouse input source.
(make-pen-input)
Return a new action pen input source.
Return a new action pen input source.
(make-pointer-input type)
Return a new action pointer input source of pointer type
.
Return a new action pointer input source of pointer `type`.
(make-touch-input)
Return a new action touch input source.
Return a new action touch input source.
(maximize driver)
Have driver
make the current browser window as large as your screen allows.
Have `driver` make the current browser window as large as your screen allows. https://www.w3.org/TR/webdriver2/#dfn-maximize-window
(middle-click-on driver q)
Have driver
move mouse pointer to element found by q
then click middle mouse button.
See query
for details on q
.
Useful for opening links in a new tab.
Have `driver` move mouse pointer to element found by `q` then click middle mouse button. See [[query]] for details on `q`. Useful for opening links in a new tab.
(mouse-click-on driver btn q)
Have driver
move mouse pointer to element found by q
then click mouse-button
.
mouse-button
should be etaoin.keys/mouse-left
,etaoin.keys/mouse-middle
or etaoin.keys/mouse-right
.q
see query
for details.Have `driver` move mouse pointer to element found by `q` then click `mouse-button`. - `mouse-button` should be `etaoin.keys/mouse-left`,`etaoin.keys/mouse-middle` or `etaoin.keys/mouse-right`. - `q` see [[query]] for details.
(new-window driver window-type-hint)
Have driver
create a new window. The window-type-hint
parameter
must be either :tab
or :window
and specifies the type of window
that is desired, if supported by the browser. If successful, return
a map with keys :handle
indicating the new window handle and
:type
indicating the type of window that was actually
created (either :tab
or :window
).
Have `driver` create a new window. The `window-type-hint` parameter must be either `:tab` or `:window` and specifies the type of window that is desired, if supported by the browser. If successful, return a map with keys `:handle` indicating the new window handle and `:type` indicating the type of window that was actually created (either `:tab` or `:window`). https://www.w3.org/TR/webdriver2/#dfn-new-window
(perform-actions driver input & inputs)
Have driver
perform actions defined in input
source(s) simultaneously.
See Actions for more details.
Have `driver` perform actions defined in `input` source(s) simultaneously. See [Actions](/doc/01-user-guide.adoc#actions) for more details. https://www.w3.org/TR/webdriver2/#dfn-perform-actions
(print-page driver file)
(print-page driver file opts)
Have driver
print current HTML page to file
in PDF format.
file
can be either a string or java.io.File
, any missing parent directories are automatically created.
opts
map is optional:
:orientation
is :landscape
or :portrait
(default):scale
a number, defaults to 1
, min of 0.1
, max of 2
:background
defaults to false
:page
(default is North American Letter size 8.5x11 inches)
:width
in cm, defaults to 21.59
:height
in cm, defaults to 27.94
:margin
:top
in cm, defaults to1
:bottom
in cm, defaults to 1
:left
in cm, defaults to 1
:right
in cm, default to 1
:shrinkToFit
defaults to true
:pageRanges
a vector, 1-based pages to include, example ["1-3" "6"]
or []
for all (default)Have `driver` print current HTML page to `file` in PDF format. `file` can be either a string or `java.io.File`, any missing parent directories are automatically created. `opts` map is optional: - `:orientation` is `:landscape` or `:portrait` (default) - `:scale` a number, defaults to `1`, min of `0.1`, max of `2` - `:background` defaults to `false` - `:page` (default is North American Letter size 8.5x11 inches) - `:width` in cm, defaults to `21.59` - `:height` in cm, defaults to `27.94` - `:margin` - `:top` in cm, defaults to`1` - `:bottom` in cm, defaults to `1` - `:left` in cm, defaults to `1` - `:right` in cm, default to `1` - `:shrinkToFit` defaults to `true` - `:pageRanges` a vector, 1-based pages to include, example `["1-3" "6"]` or `[]` for all (default) https://www.w3.org/TR/webdriver2/#dfn-print-page
(query driver q)
(query driver q & more)
Use driver
to find and return the first element on current page matching q
.
Query q
can be:
:active
the current active element. Note that this is deprecated.
Use get-active-element
instead to find the currently active element.:my-id
{:id "my-id"}
for ids that cannot be represented as keywords):active
conflicts with this usage and therefore you
cannot search for a keyword named :active
and expect to find an element
with ID equal to "active". In this case, use {:id "active"}
.use-css
, with-css
, use-xpath
, with-xpath
for methods
changing the driver's locator setting.
".//input[@id='uname'][@name='username']"
"input#uname[name='username']"
:xpath
or :css
:
{:xpath ".//input[@id='uname']"
}`{:css "input#uname[name='username']"}
{:tag :div}
".//div"
{:tag :div} ".//input[@id='uname']"
[{:tag :div} ".//input[@id='uname']"]
Returns the final element's unique identifier, or throws if any element
is not found.See Selecting Elements for more details.
Makes use of:
Use `driver` to find and return the first element on current page matching `q`. Query `q` can be: - `:active` the current active element. Note that this is deprecated. Use [[get-active-element]] instead to find the currently active element. - a keyword to find element by it's ID attribute: - `:my-id` - (use `{:id "my-id"}` for ids that cannot be represented as keywords) - Note that `:active` conflicts with this usage and therefore you cannot search for a keyword named `:active` and expect to find an element with ID equal to "active". In this case, use `{:id "active"}`. - a string that contains either an XPath or CSS expression, depending on the driver's locator setting. Defaults to XPath. See [[use-css]], [[with-css]], [[use-xpath]], [[with-xpath]] for methods changing the driver's locator setting. - XPath: `".//input[@id='uname'][@name='username']"` - CSS: `"input#uname[name='username']"` - a map with either `:xpath` or `:css`: - `{:xpath ".//input[@id='uname']"`}` - `{:css "input#uname[name='username']"}` - any other map is converted to an XPath expression: - `{:tag :div}` - is equivalent to XPath: `".//div"` - multiple of the above (wrapped in a vector or not). The result of each search anchors the search for the next, effectively providing a path through the DOM (though you do not have to specify each and every point in the path). - `{:tag :div} ".//input[@id='uname']"` - `[{:tag :div} ".//input[@id='uname']"]` Returns the final element's unique identifier, or throws if any element is not found. See [Selecting Elements](/doc/01-user-guide.adoc#querying) for more details. Makes use of: - https://www.w3.org/TR/webdriver2/#dfn-get-active-element - https://www.w3.org/TR/webdriver2/#dfn-find-element - https://www.w3.org/TR/webdriver2/#dfn-find-element-from-element
(query-all driver q)
(query-all driver q & more)
Use driver
to return a vector of all elements on current page matching q
.
See query
for details on q
.
Makes use of:
Use `driver` to return a vector of all elements on current page matching `q`. See [[query]] for details on `q`. Makes use of: - https://www.w3.org/TR/webdriver2/#dfn-find-elements - https://www.w3.org/TR/webdriver2/#dfn-find-elements-from-element
(query-all-from driver el q)
Use driver
to return a vector of elements satisfying query q
,
starting the search at the element specified by el
. If q
is a
vector of queries, then the search starts from el
and identifies
single candidates for the first item in q
, and then uses that
element as the root of the next search, with the exception of the
last item, which is then searched for all matching
elements. query-all-from
is similar to query-all
but starts the
search from el
rather than the DOM root.
See query
for details on q
.
https://www.w3.org/TR/webdriver2/#dfn-find-elements-from-element
Use `driver` to return a vector of elements satisfying query `q`, starting the search at the element specified by `el`. If `q` is a vector of queries, then the search starts from `el` and identifies single candidates for the first item in `q`, and then uses that element as the root of the next search, with the exception of the last item, which is then searched for all matching elements. `query-all-from` is similar to `query-all` but starts the search from `el` rather than the DOM root. See [[query]] for details on `q`. https://www.w3.org/TR/webdriver2/#dfn-find-elements-from-element
(query-all-from-shadow-root driver q shadow-q)
First, conducts a standard search (as if by query
) for an element
with a shadow root. Then, from that shadow root element, conducts a
search of the shadow DOM for all elements matching shadow-q
.
For details on q
, see query
.
The shadow-q
parameter is similar to the q
parameter of
the query
function, but some drivers may limit it to specific
formats (e.g., CSS). See this note for more information.
Note that shadow-q
does not support query
's :active
keyword.
First, conducts a standard search (as if by [[query]]) for an element with a shadow root. Then, from that shadow root element, conducts a search of the shadow DOM for all elements matching `shadow-q`. For details on `q`, see [[query]]. The `shadow-q` parameter is similar to the `q` parameter of the [[query]] function, but some drivers may limit it to specific formats (e.g., CSS). See [this note](/doc/01-user-guide.adoc#shadow-root-browser-limitations) for more information. Note that `shadow-q` does not support `query`'s `:active` keyword.
(query-all-from-shadow-root-el driver shadow-root-el shadow-q)
Queries the shadow DOM rooted at shadow-root-el
, looking for all
elements specified by shadow-q
.
The shadow-q
parameter is similar to the q
parameter of
the query
function, but some drivers may limit it to specific
formats (e.g., CSS). See this note for more information.
Note that shadow-q
does not support query
's :active
keyword.
https://www.w3.org/TR/webdriver2/#dfn-find-elements-from-shadow-root
Queries the shadow DOM rooted at `shadow-root-el`, looking for all elements specified by `shadow-q`. The `shadow-q` parameter is similar to the `q` parameter of the [[query]] function, but some drivers may limit it to specific formats (e.g., CSS). See [this note](/doc/01-user-guide.adoc#shadow-root-browser-limitations) for more information. Note that `shadow-q` does not support `query`'s `:active` keyword. https://www.w3.org/TR/webdriver2/#dfn-find-elements-from-shadow-root
(query-from driver el q)
Use driver
to return a single element satisfying query q
,
starting the search at the element specified by el
. query-from
is similar to query
but starts the search from el
rather than
the DOM root.
See query
for details on q
.
https://www.w3.org/TR/webdriver2/#dfn-find-element-from-element
Use `driver` to return a single element satisfying query `q`, starting the search at the element specified by `el`. `query-from` is similar to `query` but starts the search from `el` rather than the DOM root. See [[query]] for details on `q`. https://www.w3.org/TR/webdriver2/#dfn-find-element-from-element
(query-from-shadow-root driver q shadow-q)
First, conducts a standard search (as if by query
) for an element
with a shadow root. Then, from that shadow root element, conducts a
search of the shadow DOM for the first element matching shadow-q
.
For details on q
, see query
.
The shadow-q
parameter is similar to the q
parameter of
the query
function, but some drivers may limit it to specific
formats (e.g., CSS). See this note for more information.
Note that shadow-q
does not support query
's :active
keyword.
First, conducts a standard search (as if by [[query]]) for an element with a shadow root. Then, from that shadow root element, conducts a search of the shadow DOM for the first element matching `shadow-q`. For details on `q`, see [[query]]. The `shadow-q` parameter is similar to the `q` parameter of the [[query]] function, but some drivers may limit it to specific formats (e.g., CSS). See [this note](/doc/01-user-guide.adoc#shadow-root-browser-limitations) for more information. Note that `shadow-q` does not support `query`'s `:active` keyword.
(query-from-shadow-root-el driver shadow-root-el shadow-q)
Queries the shadow DOM rooted at shadow-root-el
, looking for the
first element specified by shadow-q
.
The shadow-q
parameter is similar to the q
parameter of
the query
function, but some drivers may limit it to specific
formats (e.g., CSS). See this note for more information.
Note that shadow-q
does not support query
's :active
keyword.
https://www.w3.org/TR/webdriver2/#dfn-find-element-from-shadow-root
Queries the shadow DOM rooted at `shadow-root-el`, looking for the first element specified by `shadow-q`. The `shadow-q` parameter is similar to the `q` parameter of the [[query]] function, but some drivers may limit it to specific formats (e.g., CSS). See [this note](/doc/01-user-guide.adoc#shadow-root-browser-limitations) for more information. Note that `shadow-q` does not support `query`'s `:active` keyword. https://www.w3.org/TR/webdriver2/#dfn-find-element-from-shadow-root
(query-tree driver q & qs)
Use driver
to return a collection of all elements matching piped queries.
The results of q
are queried by qs1
which in turn are queried by qs2
, and so on.
See query
for details on q
.
See User Guide for an example.
Makes use of:
Use `driver` to return a collection of all elements matching piped queries. The results of `q` are queried by `qs1` which in turn are queried by `qs2`, and so on. See [[query]] for details on `q`. See [User Guide](/doc/01-user-guide.adoc#query-tree) for an example. Makes use of: - https://www.w3.org/TR/webdriver2/#dfn-find-elements - https://www.w3.org/TR/webdriver2/#dfn-find-elements-from-element
(quit driver)
Have driver
close the current session, then, if Etaoin launched it, kill the WebDriver process.
Have `driver` close the current session, then, if Etaoin launched it, kill the WebDriver process.
(rand-uuid)
Return a random UUID string.
Return a random UUID string.
(refresh driver)
Have driver
reload the content in the current browser window.
Have `driver` reload the content in the current browser window. https://www.w3.org/TR/webdriver2/#dfn-refresh
(release-actions driver)
Have driver
clear any active action state.
This includes any key presses and/or a pointer button being held down.
Have `driver` clear any active action state. This includes any key presses and/or a pointer button being held down. https://www.w3.org/TR/webdriver2/#release-actions
(remote-file remote-file-path)
Wraps remote-file-path
for use with upload-file
to avoid local file existence check.
Example usage:
(upload-file (remote-file "C:/Users/hello/url.txt"))
Wraps `remote-file-path` for use with [[upload-file]] to avoid local file existence check. Example usage: ```Clojure (upload-file (remote-file "C:/Users/hello/url.txt")) ```
(right-click-on driver q)
Have driver
move mouse pointer to element found by q
then click right mouse button.
See query
for details on q
.
Have `driver` move mouse pointer to element found by `q` then click right mouse button. See [[query]] for details on `q`.
(running? driver)
Return true if driver
seems accessable via its :host
and :port
.
Throws
:webdriver-url
Return true if `driver` seems accessable via its `:host` and `:port`. Throws - if using `:webdriver-url` - if driver process is found not be running
(safari)
(safari opts)
Launch and return a Safari driver.
opts
map is optionally, see Driver Options.
Launch and return a Safari driver. `opts` map is optionally, see [Driver Options](/doc/01-user-guide.adoc#driver-options).
(safari? driver)
Returns true if a driver
is Safari.
Returns true if a `driver` is Safari.
(screenshot driver file)
Have driver
save a PNG format screenshot of the current page to file
.
Throws if screenshot is empty.
file
can be either a string or java.io.File
, any missing parent directories are automatically created.
Have `driver` save a PNG format screenshot of the current page to `file`. Throws if screenshot is empty. `file` can be either a string or `java.io.File`, any missing parent directories are automatically created. https://www.w3.org/TR/webdriver2/#dfn-take-screenshot
(screenshot-element driver q file)
Have driver
save a PNG format screenshot of the element found by query q
to file
.
See query
for details on q
.
file
can be either a string or java.io.File
, any missing parent directories are automatically created.
https://www.w3.org/TR/webdriver2/#dfn-take-element-screenshot
Have `driver` save a PNG format screenshot of the element found by query `q` to `file`. See [[query]] for details on `q`. `file` can be either a string or `java.io.File`, any missing parent directories are automatically created. https://www.w3.org/TR/webdriver2/#dfn-take-element-screenshot
(scroll driver {:keys [x y]})
(scroll driver x y)
Have driver
scroll page to x
y
absolute pixel coordinates.
Have `driver` scroll page to `x` `y` absolute pixel coordinates.
(scroll-bottom driver)
Have driver
scroll vertically to bottom of the page keeping current horizontal position.
Have `driver` scroll vertically to bottom of the page keeping current horizontal position.
(scroll-by driver {:keys [x y]})
(scroll-by driver x y)
Have driver
scroll by x
y
relative pixel offset.
Have `driver` scroll by `x` `y` relative pixel offset.
(scroll-down driver)
(scroll-down driver offset)
Have driver
scroll the page down by offset
pixels.
offset
defaults to scroll-offset
.
Have `driver` scroll the page down by `offset` pixels. `offset` defaults to [[scroll-offset]].
(scroll-left driver)
(scroll-left driver offset)
Have driver
scroll the page left by offset
pixels.
offset
defaults to scroll-offset
.
Have `driver` scroll the page left by `offset` pixels. `offset` defaults to [[scroll-offset]].
Default scroll offset in pixels.
Default scroll offset in pixels.
(scroll-query driver q)
(scroll-query driver q param)
Have driver
scroll to the element found by query q
.
See query
for details on q
.
Invokes element's .scrollIntoView()
method. Accepts extra param
argument that might be either boolean or object for more control.
See Mozilla's docs for values.
Have `driver` scroll to the element found by query `q`. See [[query]] for details on `q`. Invokes element's `.scrollIntoView()` method. Accepts extra `param` argument that might be either boolean or object for more control. See [Mozilla's docs for values](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView).
(scroll-right driver)
(scroll-right driver offset)
Have driver
scroll the page right by offset
pixels.
offset
defaults to scroll-offset
.
Have `driver` scroll the page right by `offset` pixels. `offset` defaults to [[scroll-offset]].
(scroll-top driver)
Have driver
scroll vertically to the top of the page keeping current horizontal position.
Have `driver` scroll vertically to the top of the page keeping current horizontal position.
(scroll-up driver)
(scroll-up driver offset)
Have driver
scroll the page up by offset
pixels.
offset
defaults to scroll-offset
.
Have `driver` scroll the page up by `offset` pixels. `offset` defaults to [[scroll-offset]].
(select driver q text)
Convenience function to have driver
select first option that includes text
for select element found by query q
.
To appease a quirk of the Safari WebDriver, we click on the select element first, then the option. Other WebDriver implementations do not seem to need, but are not negatively impacted by, the click on the select element.
See query
for details on q
.
See User Guide for other ways to select options from dropdowns.
Convenience function to have `driver` select first option that includes `text` for select element found by query `q`. To appease a quirk of the Safari WebDriver, we click on the select element first, then the option. Other WebDriver implementations do not seem to need, but are not negatively impacted by, the click on the select element. See [[query]] for details on `q`. See [User Guide](/doc/01-user-guide.adoc#select-dropdown) for other ways to select options from dropdowns.
(selected-el? driver el)
Return true if driver
determines element el
is selected.
For use on input elements like checkboxes, radio buttons and option elements.
Return true if `driver` determines element `el` is selected. For use on input elements like checkboxes, radio buttons and option elements. https://www.w3.org/TR/webdriver2/#dfn-is-element-selected
(selected? driver q)
Return true if driver
determines element found by query q
is selected.
See query
for details on q
.
For use on input elements like checkboxes, radio buttons and option elements.
Return true if `driver` determines element found by query `q` is selected. See [[query]] for details on `q`. For use on input elements like checkboxes, radio buttons and option elements.
(set-cookie driver cookie)
Have driver
set a cookie
.
cookie
is a map with structure described in get-cookies
.
At least :name
and :value
keys should be populated.
Have `driver` set a `cookie`. `cookie` is a map with structure described in [[get-cookies]]. At least `:name` and `:value` keys should be populated. https://www.w3.org/TR/webdriver2/#dfn-adding-a-cookie
(set-hash driver hash)
Have driver
set a new hash
fragment for the current page.
Don't include the leading #
character in hash
.
Useful when navigating on single page applications. See also: get-hash
.
Have `driver` set a new `hash` fragment for the current page. Don't include the leading `#` character in `hash`. Useful when navigating on single page applications. See also: [[get-hash]].
(set-implicit-timeout driver seconds)
Sets driver
timeout seconds
for finding elements on the page.
Sets `driver` timeout `seconds` for finding elements on the page.
(set-page-load-timeout driver seconds)
Sets driver
timeout seconds
for loading a page.
Sets `driver` timeout `seconds` for loading a page.
(set-script-timeout driver seconds)
Sets driver
timeout seconds
for executing JavaScript.
Sets `driver` timeout `seconds` for executing JavaScript.
(set-timeouts driver timeouts)
Set millisecond
timeouts for any of :script
:pageLoad
implicit
.
Note the capitilization of :pageLoad
.
Set `millisecond` timeouts for any of `:script` `:pageLoad` `implicit`. Note the capitilization of `:pageLoad`. https://www.w3.org/TR/webdriver2/#dfn-set-timeouts
(set-window-position driver {:keys [x y]})
(set-window-position driver x y)
Have driver
set the x
y
position of the current browser window.
Position is in pixels and relative to your screen. Absolute precision is not guaranteed.
Condiser also: set-window-rect
Have `driver` set the `x` `y` position of the current browser window. Position is in pixels and relative to your screen. Absolute precision is not guaranteed. Condiser also: [[set-window-rect]]
(set-window-rect driver {:keys [width height x y]})
Have driver
ase the current browser window :width
, :height
, :x
and/or :y
.
Have `driver` ase the current browser window `:width`, `:height`, `:x` and/or `:y`. https://www.w3.org/TR/webdriver2/#dfn-set-window-rect
(set-window-size driver {:keys [width height]})
(set-window-size driver width height)
Have driver
set the width
and height
in pixels of the current window.
Absolute precision is not guaranteed.
Condiser also: set-window-rect
Have `driver` set the `width` and `height` in pixels of the current window. Absolute precision is not guaranteed. Condiser also: [[set-window-rect]]
(stop-driver driver)
Returns new driver
after killing its WebDriver process.
Returns new `driver` after killing its WebDriver process.
(submit driver q)
Have driver
submit a form by sending the enter key to input element found by query q
.
See query
for details on q
.
Have `driver` submit a form by sending the enter key to input element found by query `q`. See [[query]] for details on `q`.
(supports-logs? driver)
Returns true if driver
supports getting console logs.
Returns true if `driver` supports getting console logs.
(switch-frame driver q)
Have driver
switch context to (i)frame element found by query q
.
See query
for details on q
.
Have `driver` switch context to (i)frame element found by query `q`. See [[query]] for details on `q`. https://www.w3.org/TR/webdriver2/#dfn-switch-to-frame
(switch-frame-first driver)
Have driver
switch context to the first (i)frame.
Have `driver` switch context to the first (i)frame.
(switch-frame-parent driver)
Have driver
switch context to the parent of the current (i)frame.
https://www.w3.org/TR/webdriver2/#dfn-switch-to-parent-frame
Have `driver` switch context to the parent of the current (i)frame. https://www.w3.org/TR/webdriver2/#dfn-switch-to-parent-frame
(switch-frame-top driver)
Have driver
switch context the main page.
Have `driver` switch context the main page.
(switch-window driver handle)
Have driver
switch to browser window with handle
.
Have `driver` switch to browser window with `handle`. https://www.w3.org/TR/webdriver2/#dfn-switch-to-window
(switch-window-next driver)
A convenience fn to have driver
switch to next browser window.
A convenience fn to have `driver` switch to next browser window.
(touch-tap driver q)
Have driver
touch tap element found by query q
.
See query
for details on q
.
Have `driver` touch tap element found by query `q`. See [[query]] for details on `q`.
(upload-file driver q path)
Have driver
attach a file path
to a file input field element found by query q
.
Arguments:
q
see query
for details;file
remote-file
file is assumed to exist remotely and no local existence check is performed.Under the hood, we send the file's name as a sequence of keys to the input.
Have `driver` attach a file `path` to a file input field element found by query `q`. Arguments: - `q` see [[query]] for details; - `file` - when a string or java.io.File object, the file must exist locally. - when [[remote-file]] file is assumed to exist remotely and no local existence check is performed. Under the hood, we send the file's name as a sequence of keys to the input.
(use-css driver)
Return new driver
with default locator set to CSS.
Return new `driver` with default locator set to CSS.
(use-xpath driver)
Return new driver
with default locator set to XPath.
Return new `driver` with default locator set to XPath.
(visible? driver q)
Return true if element found by driver
with query q
exists and is effectively displayed.
See query
for details on q
.
Same as displayed?
but does not throw if element does not exist.
Return true if element found by `driver` with query `q` exists and is effectively displayed. See [[query]] for details on `q`. Same as [[displayed?]] but does not throw if element does not exist.
(wait seconds)
(wait driver seconds)
Sleep for seconds
.
Sleep for `seconds`.
(wait-absent driver q & [opts])
Waits until driver
determines element is not found by q
(is absent?
).
See query
for details on q
.
opts
: see wait-predicate
opts.Waits until `driver` determines element is not found by `q` (is [[absent?]]). See [[query]] for details on `q`. - `opts`: see [[wait-predicate]] opts.
(wait-disabled driver q & [opts])
Waits until driver
determines element found by q
is disabled?
.
See query
for details on q
.
opts
: see wait-predicate
opts.Waits until `driver` determines element found by `q` is [[disabled?]]. See [[query]] for details on `q`. - `opts`: see [[wait-predicate]] opts.
(wait-enabled driver q & [opts])
Waits until driver
determines element found by q
is enabled?
.
See query
for details on q
.
opts
: see wait-predicate
opts.Waits until `driver` determines element found by `q` is [[enabled?]]. See [[query]] for details on `q`. - `opts`: see [[wait-predicate]] opts.
(wait-exists driver q & [opts])
Waits until driver
finds element exists?
via q
.
opts
: see wait-predicate
opts.Waits until `driver` finds element [[exists?]] via `q`. - `opts`: see [[wait-predicate]] opts.
(wait-has-alert driver & [opts])
Waits until driver
finds page has-alert?
.
opts
: see wait-predicate
opts.Waits until `driver` finds page [[has-alert?]]. - `opts`: see [[wait-predicate]] opts.
(wait-has-class driver q class & [opts])
Waits until driver
finds element via q
has-class?
class
.
See query
for details on q
.
opts
: see wait-predicate
opts.Waits until `driver` finds element via `q` [[has-class?]] `class`. See [[query]] for details on `q`. - `opts`: see [[wait-predicate]] opts.
(wait-has-text driver q text & [opts])
Waits until driver
finds element via q
with text
anywhere inside it (including inner HTML).
See query
for details on q
.
opts
: see wait-predicate
opts.Waits until `driver` finds element via `q` with `text` anywhere inside it (including inner HTML). See [[query]] for details on `q`. - `opts`: see [[wait-predicate]] opts.
(wait-has-text-everywhere driver text & [opts])
Waits until driver
finds text
anywhere on the current page.
opts
: see wait-predicate
opts.Waits until `driver` finds `text` anywhere on the current page. - `opts`: see [[wait-predicate]] opts.
(wait-invisible driver q & [opts])
Waits until driver
determines element found by q
is invisible?
.
See query
for details on q
.
opts
: see wait-predicate
opts.Waits until `driver` determines element found by `q` is [[invisible?]]. See [[query]] for details on `q`. - `opts`: see [[wait-predicate]] opts.
(wait-predicate pred)
(wait-predicate pred opts)
Wakes up every :interval
seconds to call pred
.
Keeps this up until either pred
returns truthy or :timeout
has elapsed.
When :timeout
has elapsed a slingshot exception is throws with :message
.
Arguments:
pred
: a zero-argument predicate to callopts
: a map of optional parameters:
:timeout
wait limit in seconds, *wait-timeout*
by default;:interval
how long to wait between calls, *wait-interval*
by default;:message
a message that becomes a part of exception when timeout is reached.Wakes up every `:interval` seconds to call `pred`. Keeps this up until either `pred` returns truthy or `:timeout` has elapsed. When `:timeout` has elapsed a slingshot exception is throws with `:message`. Arguments: - `pred`: a zero-argument predicate to call - `opts`: a map of optional parameters: - `:timeout` wait limit in seconds, [[*wait-timeout*]] by default; - `:interval` how long to wait between calls, [[*wait-interval*]] by default; - `:message` a message that becomes a part of exception when timeout is reached.
(wait-running driver & [opts])
Waits until driver
is reachable via its host and port via running?
.
Throws
if using :webdriver-url
.
if driver process is found to be no longer running while waiting
opts
: see wait-predicate
opts.
Waits until `driver` is reachable via its host and port via [[running?]]. Throws - if using `:webdriver-url`. - if driver process is found to be no longer running while waiting - `opts`: see [[wait-predicate]] opts.
(wait-visible driver q & [opts])
Waits until driver
determines element found by q
is visible?
.
See query
for details on q
.
opts
: see wait-predicate
opts.Waits until `driver` determines element found by `q` is [[visible?]]. See [[query]] for details on `q`. - `opts`: see [[wait-predicate]] opts.
(when-chrome driver & body)
Executes body
when browser driver
is Chrome.
Executes `body` when browser `driver` is Chrome.
(when-edge driver & body)
Executes body
when browser driver
is Edge.
Executes `body` when browser `driver` is Edge.
(when-firefox driver & body)
Executes body
when browser driver
is Firefox.
Executes `body` when browser `driver` is Firefox.
(when-headless driver & body)
Executes body
when the driver
is in headless mode.
Executes `body` when the `driver` is in headless mode.
(when-not-chrome driver & body)
Executes body
when browser driver
is NOT Chrome.
Executes `body` when browser `driver` is NOT Chrome.
(when-not-drivers browsers driver & body)
Executes body
when browser driver
is NOT in browsers
, ex: #{:chrome :safari}
Executes `body` when browser `driver` is NOT in `browsers`, ex: `#{:chrome :safari}`
(when-not-edge driver & body)
Executes body
when browser driver
is NOT Edge.
Executes `body` when browser `driver` is NOT Edge.
(when-not-firefox driver & body)
Executes body
when browser driver
is NOT Firefox.
Executes `body` when browser `driver` is NOT Firefox.
(when-not-headless driver & body)
Executes body
when browser driver
is NOT in headless mode.
Executes `body` when browser `driver` is NOT in headless mode.
(when-not-predicate predicate & body)
Executes body
when predicate
returns falsy.
Deprecated: Use clojure.core/when-not
instead.
Executes `body` when `predicate` returns falsy. Deprecated: Use `clojure.core/when-not` instead.
(when-not-safari driver & body)
Executes body
when browser driver
is NOT Safari.
Executes `body` when browser `driver` is NOT Safari.
(when-predicate predicate & body)
Executes body
when predicate
returns truthy.
Deprecated: Use clojure.core/when
instead.
Executes `body` when `predicate` returns truthy. Deprecated: Use `clojure.core/when` instead.
(when-safari driver & body)
Executes body
when browser driver
is Safari.
Executes `body` when browser `driver` is Safari.
(with-chrome opts? bind & body)
Executes body
with a Chrome driver session bound to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-chrome driver
(go driver "https://clojure.org"))
Executes `body` with a Chrome driver session bound to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-chrome driver (go driver "https://clojure.org")) ```
(with-chrome-headless opts? bind & body)
Executes body
with a headless Chrome driver session bound to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-chrome-headless driver
(go driver "https://clojure.org"))
Executes `body` with a headless Chrome driver session bound to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-chrome-headless driver (go driver "https://clojure.org")) ```
(with-css driver & body)
Execute body
with default locator set to CSS.
Execute `body` with default locator set to CSS.
(with-driver type opts? bind & body)
Executes body
with a driver session of type
(e.g. :chrome
, :firefox
:safari
:edge
)
with opts
options, binding driver instance to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-driver :firefox driver
(go driver "https://clojure.org"))
Executes `body` with a driver session of `type` (e.g. `:chrome`, `:firefox` `:safari` `:edge`) with `opts` options, binding driver instance to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-driver :firefox driver (go driver "https://clojure.org")) ```
(with-edge opts? bind & body)
Executes body
with an Edge driver session bound to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-edge driver
(go driver "https://clojure.org"))
Executes `body` with an Edge driver session bound to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-edge driver (go driver "https://clojure.org")) ```
(with-edge-headless opts? bind & body)
Executes body
with a headless Edge driver session bound to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-edge-headless driver
(go driver "https://clojure.org"))
Executes `body` with a headless Edge driver session bound to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-edge-headless driver (go driver "https://clojure.org")) ```
(with-firefox bind & body)
(with-firefox opts? bind & body)
Executes body
with a Firefox driver session bound to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-firefox driver
(go driver "https://clojure.org"))
Executes `body` with a Firefox driver session bound to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-firefox driver (go driver "https://clojure.org")) ```
(with-firefox-headless opts? bind & body)
Executes body
with a headless Firefox driver session bound to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-firefox-headless driver
(go driver "https://clojure.org"))
Executes `body` with a headless Firefox driver session bound to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-firefox-headless driver (go driver "https://clojure.org")) ```
(with-frame driver q & body)
Excecute body
within context of frame found via driver
by query q
.
Frame context is restored after call.
Result of body
is returned.
Excecute `body` within context of frame found via `driver` by query `q`. Frame context is restored after call. Result of `body` is returned.
(with-http-error & body)
Executes body
suppressing catching any exception that would normally occur due to HTTP non-success status
when communicating with a WebDriver.
Instead returns false on first HTTP non-success status.
Executes `body` suppressing catching any exception that would normally occur due to HTTP non-success status when communicating with a WebDriver. Instead returns false on first HTTP non-success status.
(with-key-down input key & body)
Returns input
source piped through key
down,
then presumably a body
of more actions then a key
up action.
Returns `input` source piped through `key` down, then presumably a `body` of more actions then a `key` up action.
(with-pointer-btn-down input pointer-button & body)
Returns input
source piped through pointer-button
down action,
then presumably a body
of more actions then a pointer pointer-button
up action.
pointer-button
should be, for example, etaoin.keys/mouse-left
Returns `input` source piped through `pointer-button` down action, then presumably a `body` of more actions then a pointer `pointer-button` up action. `pointer-button` should be, for example, [[etaoin.keys/mouse-left]]
(with-pointer-left-btn-down input & body)
Returns input
source piped through pointer left button down action,
then presumably a body
of more actions then a pointer left button up action.
Returns `input` source piped through pointer left button down action, then presumably a `body` of more actions then a pointer left button up action.
(with-postmortem driver opts & body)
Executes body
with postmortem handling.
Good for forensics.
If an exception occurs, saves:
.png
to :dir-img
else :dir
else current working directory.html
to :dir-scr
else :dir
else current working directory.json
to :dir-log
else :dir
else current working directoryDirs are automatically created if necessary.
:date-format
used in filename to keep them unique.
See Java SDK SimpleDateFormat
for available patterns.
Defaults to "yyyy-MM-dd-HH-mm-ss"
.
Tip: don't bother using with-postmortem
in test fixtures.
The standard clojure.test
framework has its own way of handling exceptions,
so wrapping a fixture with (with-postmortem...)
would be in vain.
Executes `body` with postmortem handling. Good for forensics. If an exception occurs, saves: - screenshot `.png` to `:dir-img` else `:dir` else current working directory - page source `.html` to `:dir-scr` else `:dir` else current working directory - console log `.json` to `:dir-log` else `:dir` else current working directory Dirs are automatically created if necessary. `:date-format` used in filename to keep them unique. See Java SDK `SimpleDateFormat` for available patterns. Defaults to `"yyyy-MM-dd-HH-mm-ss"`. Tip: don't bother using `with-postmortem` in test fixtures. The standard `clojure.test`framework has its own way of handling exceptions, so wrapping a fixture with `(with-postmortem...)` would be in vain.
(with-safari opts? bind & body)
Executes body
with a Safari driver session bound to bind
.
Driver is automatically launched and terminated (even if an exception occurs).
opts
map can be omitted, see Driver Options.
Example:
(with-safari driver
(go driver "https://clojure.org"))
Executes `body` with a Safari driver session bound to `bind`. Driver is automatically launched and terminated (even if an exception occurs). `opts` map can be omitted, see [Driver Options](/doc/01-user-guide.adoc#driver-options). Example: ```Clojure (with-safari driver (go driver "https://clojure.org")) ```
(with-screenshots driver dir & body)
Have driver
save a PNG imge screenshot to dir
after each form in body
is executed.
Filenames will contain an epoch timestamp.
Have `driver` save a PNG imge screenshot to `dir` after each form in `body` is executed. Filenames will contain an epoch timestamp.
(with-script-timeout driver seconds & body)
Execute body
temporarily setting driver
to timeout seconds
for executing JavaScript.
Useful for asynchronous scripts.
Execute `body` temporarily setting `driver` to timeout `seconds` for executing JavaScript. Useful for asynchronous scripts.
(with-wait seconds & body)
Execute body
waiting seconds
before each form.
Returns the value of the last form.
Can be used to perform actions slowly. Some SPA applications need extra time to re-render the content.
Execute `body` waiting `seconds` before each form. Returns the value of the last form. Can be used to perform actions slowly. Some SPA applications need extra time to re-render the content.
(with-wait-interval seconds & body)
Execute body
with a *wait-interval*
of seconds
(which can be fractional).
Execute `body` with a [[*wait-interval*]] of `seconds` (which can be fractional).
(with-wait-timeout seconds & body)
Execute body
with a *wait-timeout*
of seconds
Execute `body` with a [[*wait-timeout*]] of `seconds`
(with-xpath driver & body)
Execute body
with default locator set to XPath.
Execute `body` with default locator set to XPath.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close