(->build-composite-action driver & body)
Create a composite chain of actions, then call .build()
. This does not execute the actions; it simply sets up an 'action chain' which can later by executed using .perform()
.
Unless you need to wait to execute your composite actions, you should prefer ->actions
to this macro.
Create a composite chain of actions, then call `.build()`. This does **not** execute the actions; it simply sets up an 'action chain' which can later by executed using `.perform()`. Unless you need to wait to execute your composite actions, you should prefer `->actions` to this macro.
(by-attr-contains attr value)
(by-attr-contains tag attr value)
Match if value
is contained in the value of attr
. You can optionally specify the tag.
For example: (by-attr-contains :class "navigation")
(by-attr-contains :ul :class "tags")
Match if `value` is contained in the value of `attr`. You can optionally specify the tag. For example: `(by-attr-contains :class "navigation")` `(by-attr-contains :ul :class "tags")`
(by-attr-ends attr value)
(by-attr-ends tag attr value)
Match if value
is at the end of the value of attr
. You can optionally specify the tag.
Match if `value` is at the end of the value of `attr`. You can optionally specify the tag.
(by-attr-starts attr value)
(by-attr-starts tag attr value)
Match if value
is at the beginning of the value of attr
. You can optionally specify the tag.
Match if `value` is at the beginning of the value of `attr`. You can optionally specify the tag.
(by-attr= attr value)
(by-attr= tag attr value)
Use value
of arbitrary attribute attr
to find an element. You can optionally specify the tag.
For example: (by-attr= :id "element-id")
(by-attr= :div :class "content")
Use `value` of arbitrary attribute `attr` to find an element. You can optionally specify the tag. For example: `(by-attr= :id "element-id")` `(by-attr= :div :class "content")`
(by-class-name expr)
Used when finding elements. Returns By/className
of expr
Used when finding elements. Returns `By/className` of `expr`
(by-css expr)
Used when finding elements. Returns By/cssSelector
of expr
Used when finding elements. Returns `By/cssSelector` of `expr`
(by-has-attr attr)
(by-has-attr tag attr)
Match if the element has the attribute attr
, regardless of its value. You can optionally specify the tag.
Match if the element has the attribute `attr`, regardless of its value. You can optionally specify the tag.
(by-id expr)
Used when finding elements. Returns By/id
of expr
Used when finding elements. Returns `By/id` of `expr`
(by-link-text expr)
Used when finding elements. Returns By/linkText
of expr
Used when finding elements. Returns `By/linkText` of `expr`
(by-name expr)
Used when finding elements. Returns By/name
of expr
Used when finding elements. Returns `By/name` of `expr`
(by-partial-link-text expr)
Used when finding elements. Returns By/partialLinkText
of expr
Used when finding elements. Returns `By/partialLinkText` of `expr`
(by-query {:keys [xpath css] :as m})
Given a map with either an :xpath
or :css
key, return the respective by-* function (by-xpath
or by-css
) using the value for that key.
Given a map with either an `:xpath` or `:css` key, return the respective by-* function (`by-xpath` or `by-css`) using the value for that key.
(by-tag expr)
Used when finding elements. Returns By/tagName
of expr
Used when finding elements. Returns `By/tagName` of `expr`
(by-xpath expr)
Used when finding elements. Returns By/xpath
of expr
Used when finding elements. Returns `By/xpath` of `expr`
(execute-script* driver js & js-args)
Version of execute-script that uses a WebDriver instance directly.
Version of execute-script that uses a WebDriver instance directly.
Methods available in the Actions class
Methods available in the Actions class
(move-by-offset driver x y)
Move mouse by x
pixels to the right and y
pixels down.
Move mouse by `x` pixels to the right and `y` pixels down.
(double-click this)
(double-click this element)
Double click, either at the current mouse position or in the middle of a given element
.
Double click, either at the current mouse position or in the middle of a given `element`.
(release this)
(release this element)
Release the left mouse button, either at the current mouse position or in the middle of the given element
.
Release the left mouse button, either at the current mouse position or in the middle of the given `element`.
(key-down this k)
(key-down this element k)
Press the given key (e.g., (key-press driver :enter))
Press the given key (e.g., (key-press driver :enter))
(drag-and-drop this element-a element-b)
Drag and drop element-a
onto element-b
.
Drag and drop `element-a` onto `element-b`.
(perform this)
Perform the composite action chain.
Perform the composite action chain.
(drag-and-drop-by this element x-y-map)
Drag element
by x
pixels to the right and y
pixels down.
Drag `element` by `x` pixels to the right and `y` pixels down.
(click-and-hold this)
(click-and-hold this element)
Drag and drop, either at the current mouse position or in the middle of a given element
.
Drag and drop, either at the current mouse position or in the middle of a given `element`.
(move-to-element this element)
(move-to-element this element x y)
Move the mouse to the given element, or to an offset from the given element.
Move the mouse to the given element, or to an offset from the given element.
(key-up this k)
(key-up this element k)
Release the given key (e.g., (key-press driver :enter))
Release the given key (e.g., (key-press driver :enter))
Simple interactions with alert popups
Simple interactions with alert popups
(accept driver)
Accept the dialog. Equivalent to pressing 'Ok'
Accept the dialog. Equivalent to pressing 'Ok'
(alert-obj driver)
Return the underlying Java object that can be used with the Alert Java API (exposed until all functionality is ported)
Return the underlying Java object that can be used with the Alert Java API (exposed until all functionality is ported)
(alert-text driver)
Get the text of the popup dialog's message
Get the text of the popup dialog's message
(dismiss driver)
Dismiss the dialog. Equivalent to pressing 'Cancel'
Dismiss the dialog. Equivalent to pressing 'Cancel'
Basics of driver handling
Basics of driver handling
(quit driver)
Destroy this browser instance
Destroy this browser instance
(page-source driver)
Retrieve the source code of the current page
Retrieve the source code of the current page
(current-url driver)
Retrieve the URL of the current page
Retrieve the URL of the current page
(to driver url)
Navigate to a particular URL. Arg url
can be either String or java.net.URL. Equivalent to the get
function, provided here for compatibility with WebDriver API.
Navigate to a particular URL. Arg `url` can be either String or java.net.URL. Equivalent to the `get` function, provided here for compatibility with WebDriver API.
(get-url driver url)
Navigate the driver to a given URL
Navigate the driver to a given URL
(refresh driver)
Refresh the current page
Refresh the current page
(forward driver)
Go forward to the next page in "browsing history".
Go forward to the next page in "browsing history".
(get-screenshot driver)
(get-screenshot driver format)
(get-screenshot driver format destination)
Take a screenshot using Selenium-WebDriver's getScreenshotAs method
Take a screenshot using Selenium-WebDriver's getScreenshotAs method
(close driver)
Close this browser instance, switching to an active one if more than one is open
Close this browser instance, switching to an active one if more than one is open
(title driver)
Retrieve the title of the current page as defined in the head
tag
Retrieve the title of the current page as defined in the `head` tag
(back driver)
Go back to the previous page in "browsing history"
Go back to the previous page in "browsing history"
Basic actions on elements
Basic actions on elements
(tag element)
Retrieve the name of the HTML tag of the given element object (returned as a keyword)
Retrieve the name of the HTML tag of the given element object (returned as a keyword)
(present? element)
Returns true if the element exists and is visible
Returns true if the element exists and is visible
(location element)
Given an element object, return its location as a map of its x/y coordinates
Given an element object, return its location as a map of its x/y coordinates
(text element)
Retrieve the content, or inner HTML, of a given element object
Retrieve the content, or inner HTML, of a given element object
(html element)
Retrieve the outer HTML of an element
Retrieve the outer HTML of an element
(attribute element attr)
Retrieve the value of the attribute of the given element object
Retrieve the value of the attribute of the given element object
(location-once-visible element)
Given an element object, return its location on the screen once it is scrolled into view as a map of its x/y coordinates. The window will scroll as much as possible until the element hits the top of the page; thus even visible elements will be scrolled until they reach that point.
Given an element object, return its location on the screen once it is scrolled into view as a map of its x/y coordinates. The window will scroll as much as possible until the element hits the top of the page; thus even visible elements will be scrolled until they reach that point.
(visible? element)
Returns true if the given element object is visible/displayed
Returns true if the given element object is visible/displayed
(intersects? element-a element-b)
Return true if element-a
intersects with element-b
. This mirrors the Selenium-WebDriver API method, but see the intersect?
function to compare an element against multiple other elements for intersection.
Return true if `element-a` intersects with `element-b`. This mirrors the Selenium-WebDriver API method, but see the `intersect?` function to compare an element against multiple other elements for intersection.
(value element)
Retrieve the value
attribute of the given element object
Retrieve the `value` attribute of the given element object
(flash element)
Flash the element in question, to verify you're looking at the correct element
Flash the element in question, to verify you're looking at the correct element
(xpath element)
Retrieve the XPath of an element
Retrieve the XPath of an element
(css-value element property)
Return the value of the given CSS property
Return the value of the given CSS property
(size element)
Return the size of the given element
as a map containing :width
and :height
values in pixels.
Return the size of the given `element` as a map containing `:width` and `:height` values in pixels.
(click element)
Click a particular HTML element
Click a particular HTML element
(displayed? element)
Returns true if the given element object is visible/displayed
Returns true if the given element object is visible/displayed
(exists? element)
Returns true if the given element exists
Returns true if the given element exists
(focus element)
Apply focus to the given element
Apply focus to the given element
Functions used to locate elements on a given page
Functions used to locate elements on a given page
(find-window driver attr-val)
Given a browser driver
and a map of attributes, return the windows that match
Given a browser `driver` and a map of attributes, return the windows that match
(find-elements-by this by)
Retrieve a seq of element objects described by by
, optionally limited to elements beneath a parent element (depends on dispatch). Prefer find-elements
to this function unless you know what you're doing.
Retrieve a seq of element objects described by `by`, optionally limited to elements beneath a parent element (depends on dispatch). Prefer `find-elements` to this function unless you know what you're doing.
(find-elements this locator)
Find all elements that match the parameters supplied in the attr-val
map. Also provides a shortcut to find-by-hierarchy
if a vector is supplied instead of a map.
Find all elements that match the parameters supplied in the `attr-val` map. Also provides a shortcut to `find-by-hierarchy` if a vector is supplied instead of a map.
(find-by-hierarchy driver hierarchy-vector)
Given a Webdriver driver
and a vector hierarchy-vector
, return a lazy seq of the described elements in the hierarchy dictated by the order of elements in the hierarchy-vector
.
Given a Webdriver `driver` and a vector `hierarchy-vector`, return a lazy seq of the described elements in the hierarchy dictated by the order of elements in the `hierarchy-vector`.
(find-windows driver attr-val)
Given a browser driver
and a map of attributes, return the windows that match
Given a browser `driver` and a map of attributes, return the windows that match
(find-table-row driver table row-index)
Return all cells in the row of the given table element, row-index
as a zero-based index of the target row.
Return all cells in the row of the given table element, `row-index` as a zero-based index of the target row.
(find-element-by this by)
Retrieve the element object of an element described by by
, optionally limited to elements beneath a parent element (depends on dispatch). Prefer find-element
to this function unless you know what you're doing.
Retrieve the element object of an element described by `by`, optionally limited to elements beneath a parent element (depends on dispatch). Prefer `find-element` to this function unless you know what you're doing.
(find-table-cell driver table coordinates)
Given a driver
, a table
element, and a zero-based set of coordinates for row and column, return the table cell at those coordinates for the given table.
Given a `driver`, a `table` element, and a zero-based set of coordinates for row and column, return the table cell at those coordinates for the given table.
(find-element this locator)
Call (first (find-elements args))
Call (first (find-elements args))
Actions for form elements
Actions for form elements
(selected? element)
Returns true if the given element object is selected
Returns true if the given element object is selected
(select element)
Select a given element object
Select a given element object
(clear element)
Clear the contents of the given element object
Clear the contents of the given element object
(deselect element)
Deselect a given element object
Deselect a given element object
(input-text element s)
Type the string of keys into the element object
Type the string of keys into the element object
(submit element)
Submit the form which contains the given element object
Submit the form which contains the given element object
(send-keys element s)
Type the string of keys into the element object
Type the string of keys into the element object
(toggle element)
If the given element object is a checkbox, this will toggle its selected/unselected state. In Selenium 2, .toggle()
was deprecated and replaced in usage by .click()
.
If the given element object is a checkbox, this will toggle its selected/unselected state. In Selenium 2, `.toggle()` was deprecated and replaced in usage by `.click()`.
(enabled? element)
Returns true if the given element object is enabled
Returns true if the given element object is enabled
Actions specific to select lists
Actions specific to select lists
(select-by-value select-element value)
Select all options with value value
in the select list described by by
Select all options with value `value` in the select list described by `by`
(select-by-index select-element idx)
Select an option by its index in the given select list. Indeces begin at 0.
Select an option by its index in the given select list. Indeces begin at 0.
(deselect-by-text select-element text)
Deselect all options with visible text text
for the select list described by by
Deselect all options with visible text `text` for the select list described by `by`
(select-option select-element attr-val)
Select an option from a select list, either by :value
, :index
or :text
Select an option from a select list, either by `:value`, `:index` or `:text`
(all-selected-options select-element)
Retrieve a seq of all selected options from the select list described by by
Retrieve a seq of all selected options from the select list described by `by`
(select-by-text select-element text)
Select all options with visible text text
in the select list described by by
Select all options with visible text `text` in the select list described by `by`
(deselect-all select-element)
Deselect all options for a given select list. Does not leverage WebDriver method because WebDriver's isMultiple method is faulty.
Deselect all options for a given select list. Does not leverage WebDriver method because WebDriver's isMultiple method is faulty.
(first-selected-option select-element)
Retrieve the first selected option (or the only one for single-select lists) from the given select list
Retrieve the first selected option (or the only one for single-select lists) from the given select list
(deselect-option select-element attr-val)
Deselect an option from a select list, either by :value
, :index
or :text
Deselect an option from a select list, either by `:value`, `:index` or `:text`
(select-all select-element)
Select all options for a given select list
Select all options for a given select list
(deselect-by-index select-element idx)
Deselect the option at index idx
for the select list described by by
. Indeces begin at 0
Deselect the option at index `idx` for the select list described by `by`. Indeces begin at 0
(multiple? select-element)
Return true if the given select list allows for multiple selections
Return true if the given select list allows for multiple selections
(deselect-by-value select-element value)
Deselect all options with value value
for the select list described by by
Deselect all options with value `value` for the select list described by `by`
(all-options select-element)
Retrieve all options from the given select list
Retrieve all options from the given select list
Functions that deal with browser windows and frames
Functions that deal with browser windows and frames
(other-windows driver)
Retrieve window handles for all windows except the current one
Retrieve window handles for all windows except the current one
(switch-to-active driver)
Switch to element that currently has focus, or to the body if this cannot be detected
Switch to element that currently has focus, or to the body if this cannot be detected
(switch-to-default driver)
Switch focus to the first first frame of the page, or the main document if the page contains iframes
Switch focus to the first first frame of the page, or the main document if the page contains iframes
(switch-to-frame driver frame)
Switch focus to a particular HTML frame by supplying an Element
or an integer for the nth frame on the page (zero-based index)
Switch focus to a particular HTML frame by supplying an `Element` or an integer for the nth frame on the page (zero-based index)
(switch-to-other-window driver)
Given that two and only two browser windows are open, switch to the one not currently active
Given that two and only two browser windows are open, switch to the one not currently active
(switch-to-window driver handle)
Switch focus to a particular open window
Switch focus to a particular open window
(window driver)
Get the only (or first) window
Get the only (or first) window
(windows driver)
Retrieve a vector of Window
records which can be used to switch to particular open windows
Retrieve a vector of `Window` records which can be used to switch to particular open windows
(key-code k)
Representations of pressable keys that aren't text. These are stored in the Unicode PUA (Private Use Area) code points, 0xE000-0xF8FF. Refer to http://www.google.com.au/search?&q=unicode+pua&btnG=Search
Representations of pressable keys that aren't text. These are stored in the Unicode PUA (Private Use Area) code points, 0xE000-0xF8FF. Refer to http://www.google.com.au/search?&q=unicode+pua&btnG=Search
(new-driver browser-spec)
Start a new Driver instance. The browser-spec
can include :browser
, :profile
, and :cache-spec
keys.
The :browser
can be one of :firefox
, :ie
, :chrome
, :phantomjs
or :htmlunit
.
The :profile
should be an instance of FirefoxProfile you wish to use.
The :cache-spec
can contain :strategy
, :args
, :include
and/or `:exclude keys. See documentation on caching for more details.
Start a new Driver instance. The `browser-spec` can include `:browser`, `:profile`, and `:cache-spec` keys. The `:browser` can be one of `:firefox`, `:ie`, `:chrome`, `:phantomjs` or `:htmlunit`. The `:profile` should be an instance of FirefoxProfile you wish to use. The `:cache-spec` can contain `:strategy`, `:args`, `:include` and/or `:exclude keys. See documentation on caching for more details.
Return a Selenium-WebDriver WebDriver instance, with particularities of each browser supported.
Return a Selenium-WebDriver WebDriver instance, with particularities of each browser supported.
(other-window-handles* driver)
For consistency with other window handling functions, this starred version just returns the string-based ID's that WebDriver produces
For consistency with other window handling functions, this starred version just returns the string-based ID's that WebDriver produces
(start browser-spec url)
Shortcut to instantiate a driver, navigate to a URL, and return the driver for further use
Shortcut to instantiate a driver, navigate to a URL, and return the driver for further use
Map of keywords to available WebDriver classes.
Map of keywords to available WebDriver classes.
(window-handle* driver)
For WebDriver API compatibility: this simply wraps .getWindowHandle
For WebDriver API compatibility: this simply wraps `.getWindowHandle`
(window-handles* driver)
For WebDriver API compatibility: this simply wraps .getWindowHandles
For WebDriver API compatibility: this simply wraps `.getWindowHandles`
(with-browser & args)
Alias for with-driver
bindings => [name init ...]
Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order.
Alias for with-driver bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order.
(with-driver bindings & body)
bindings => [name init ...]
Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order.
bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close