sparkledriver.browser
accept-alert!
(accept-alert! alert)
Accept an 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.
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-options
The possible options for building a browser instance in {:option [default setter-fn]} format.
cache-dir
(cache-dir browser)
Return the path to the directory where the browser is storing cached files.
close-browser!
(close-browser! browser)
Close a browser instance, killing the underlying subprocess and freeing all resources.
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.
dismiss-alert!
(dismiss-alert! alert)
Dismisses an alert.
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’ and return browser after loading is complete.
(fetch! browser "http://www.clojure.com/")
;;=> returns browser after navigating to the clojure site
logs
(logs browser & kind)
Return browser
’s logs of whatever kind
, or all if not specified. See http://machinepublishers.github.io/jBrowserDriver/org/openqa/selenium/logging/LogEntry.html for details of the returned items. Example:
(map #(.getMessage %) (logs browser))
;;=> events that have occurred since the last time you did this
make-browser
(make-browser & options)
Creates a new headless browser instance parameterized by options
. Examples:
(make-browser :log-wire true) ; log network traffic
(make-browser :ajax-wait 1000) ; wait 1000ms for JS to run after page load
(make-browser :headless false) ; pop up a browser window to watch it work
maximize-window
(maximize-window browser)
Maximize browser
’s currently focused window.
media-dir
(media-dir browser)
Return the path to the directory where the browser is storing media files.
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 in the focused window of browser
. Text from hidden elements is not included.
page-wait
(page-wait browser)
Blocks until the browser’s current page quiesces. N.B. This is the default for many operations, so this function is likely only useful when things are misbehaving.
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.
title
(title browser)
Return the title of the current page in the focused window of browser
.
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 instance currently throws.