sparkledriver.core
accept-alert
(accept-alert alert)
all-windows
(all-windows browser)
Return a set of handles for all `browser` windows.
attachments-dir
(attachments-dir browser)
Return the path to the directory where the browser is storing attachment files.
attr
(attr element attribute)
Return the value of `attribute` for `element`
available-log-types
(available-log-types browser)
Return a set of strings representing the types of logs available for `browser`. N.B. `browser` must have been initialized with some kind of logging enabled, for isntance :log-trace or :log-wire.
browser-cookies->map
(browser-cookies->map browser)
Convert `browser`'s current cookies into the map format used by clj-http. This returns cookies from all domains, but cookie names that are set on multiple domains will only be returned once.
browser-options
The possible options for building a browser instance. The format is {:option [default setter-fn]}.
cache-dir
(cache-dir browser)
Return the path to the directory where the browser is storing cached files.
clear-text!
(clear-text! element)
Clear the current text of text-entry `element`. Used with send-text! to manipulate form fields.
click!
(click! element)
Send a browser click event to `element`.
click-all!
(click-all! elements)
Click every element in the sequence `elements`. Returns the number of elements clicked.
close-browser!
(close-browser! browser)
Close a browser instance, killing the underlying subprocess and freeing all resources.
css-value
(css-value element property)
Return the value of CSS `property` for `element`
current-url
(current-url browser)
Return the currently visited url of `browser`.
current-window
(current-window browser)
Return a handle for the currently active `browser` window.
delete-all-cookies!
(delete-all-cookies! browser)
Clear all cookies from all domains.
delete-cookie!
(delete-cookie! browser name)
(delete-cookie! browser name domain)
Delete the named cookie from the given domain. When omitted `domain` defaults to the browser's current domain.
dismiss-alert
(dismiss-alert alert)
displayed?
(displayed? element)
Is this element displayed or not? This method avoids the problem of having to parse an element's CSS.
enabled?
(enabled? element)
Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
execute-script
(execute-script browser script & arguments)
Executes JavaScript `script` in the context of the currently selected frame or window of `browser` with `arguments`.
execute-script-async
(execute-script-async browser script & arguments)
Asynchronously execute JavaScript `script` in the context of the currently selected frame or window of `browser` with `arguments`.
fetch!
(fetch! browser url)
Fetch 'url' using 'browser', return browser after loading is complete.
find-by-class
(find-by-class browser-or-elem class)
Return the first element with class name `class` that's a child of `browser-or-elem` (which can be a browser or element). Throws an exception if there's no such element!
find-by-class*
(find-by-class* browser-or-elem class)
Return all elements with class name `class` that are children of `browser-or-elem` (which can be a browser or element) or an empty sequence.
find-by-css
(find-by-css browser-or-elem css-selector)
Return the first element that matches `css-selector`, starting from `browser-or-elem` (which can be a browser or element). Throws an exception if there's no such element!
find-by-css*
(find-by-css* browser-or-elem css-selector)
Return all elements that match `css-selector`, starting from `browser-or-elem` (which can be a browser or element) or an empty sequence.
find-by-id
(find-by-id browser-or-elem id)
Return the single element with `id` that's a child of `browser-or-elem` (which can be a browser or element). Throws an exception if there's no such element!
find-by-tag
(find-by-tag browser-or-elem tag)
Return the first element with tag name `tag` that's a child of `browser-or-elem` (which can be a browser or element). Throws an exception if there's no such element!
find-by-tag*
(find-by-tag* browser-or-elem tag)
Return all elements with tag name `tag` that are children of `browser-or-elem` (which can be a browser or element) or an empty sequence.
find-by-xpath
(find-by-xpath browser-or-elem xpath)
Return the first element that matches `xpath`, starting from `browser-or-elem` (which can be a browser or element). Throws an exception if there's no such element!
find-by-xpath*
(find-by-xpath* browser-or-elem xpath)
Return all elements that match `xpath`, starting from `browser-or-elem` (which can be a browser or element) or an empty sequence.
id
(id element)
Return the value of the id attribute of `element`
inner-html
(inner-html element)
Return the innerHTML of `element`
location
(location element)
Location on the page of the top left-hand corner of the rendered element.
logs
(logs browser & kind)
make-browser
(make-browser & options)
Creates a new headless browser instance.
maximize-window
(maximize-window browser)
Maximize `browser`'s currently focused window.
outer-html
(outer-html element)
Return the outerHTML of `element`
page-source
(page-source browser)
Return the HTML source of the currently visited page in `browser`.
page-text
(page-text browser)
Return the complete visible textual content of the current page. Text from hidden elements is not included.
page-wait
(page-wait browser)
Blocks until the browser's current page quiesces.
rectangle
(rectangle element)
The location and size of the rendered element.
screenshot
(screenshot browser-or-element)
Takes a screenshot of `browser-or-element`'s current state and stores the image in a temporary file, then returns the file's absolute path.
selected?
(selected? element)
Return whether or not this element is selected
send-text!
(send-text! element text)
Send the string `text` to `element`, as if the user typed it.
set-cookie!
(set-cookie! browser name value & {domain :domain, :as options})
Set a cookie with given name and value. If a cookie with the same name and domain is already present, it will be replaced. The following keyword arguments are supported.
- :domain (String) The cookie domain, defaults to the current domain of the browser.
- :expires-on (java.util.Date) Expiration date. Must be in the future or the cookie won't be stored.
- :http-only (Boolean) Cookie's HttpOnly flag, disallow access from JavaScript
- :secure (Boolean) Cookie's Secure flag, only serve over HTTPS.
- :path (String) URL path of the cookie.
size
(size element)
What is the width and height of the rendered element?
status-code
(status-code browser)
Return the current HTTP status code of `browser`.
switch-to-alert
(switch-to-alert browser)
Switch `browser`'s focus to the current alert popup. Returns the alert's handle.
switch-to-window
(switch-to-window browser window)
Switch `browser` to `window`, which should be a handle returned by all-windows or current-window.
tag
(tag element)
Return the tag name of `element`
text
(text element)
Return the complete visible textual content of `element` (including any children). Text from hidden elements is not included.
title
(title browser)
Return the title of the current page.
with-browser
macro
(with-browser binding & body)
Evaluate `body` in a try block within which `binding` is bound, finally calling close-browser on binding. This is just a version of with-open that traps the exception that closing a jBrowserDriver currently throws. :(