Liking cljdoc? Tell your friends :D

clj-webdriver.taxi


*driver*clj

source

*finder-fn*clj

source

acceptclj

(accept)
(accept driver)

Accept an alert popup dialog. Equivalent to pressing its 'Ok' button.

Accept an alert popup dialog. Equivalent to pressing its 'Ok' button.
sourceraw docstring

(add-cookie cookie-spec)
(add-cookie driver cookie-spec)

Add a cookie to the browser session. The cookie-spec is a map which must contain :name and :value keys, and can also optionally include :domain, :path, :expiry, and :secure? (a boolean).

Examples:

;; ;; Simple example ;; (add-cookie {:name "foo", :value "bar"})

;; ;; Full example ;; (add-cookie {:name "foo", :value "bar", :domain "example.com", :path "a-path", :expiry (java.util.Date.), :secure? false})

Add a cookie to the browser session. The `cookie-spec` is a map which must contain `:name` and `:value` keys, and can also optionally include `:domain`, `:path`, `:expiry`, and `:secure?` (a boolean).

Examples:
=========

;;
;; Simple example
;;
(add-cookie {:name "foo", :value "bar"})

;;
;; Full example
;;
(add-cookie {:name "foo", :value "bar",
             :domain "example.com", :path "a-path",
             :expiry (java.util.Date.), :secure? false}) 
sourceraw docstring

alert-objclj

(alert-obj)
(alert-obj driver)

Retrieve the underlying Java object used to identify an alert popup dialog. Exposed to allow you to use methods not yet exposed via clj-webdriver's API's.

Retrieve the underlying Java object used to identify an alert popup dialog. Exposed to allow you to use methods not yet exposed via clj-webdriver's API's.
sourceraw docstring

alert-textclj

(alert-text)
(alert-text driver)

Get the text of the alert popup dialog's message.

Get the text of the alert popup dialog's message.
sourceraw docstring

attributeclj

(attribute q attr)
(attribute driver q attr)

For the first element found with query q, return the value of the given attribute.

Examples:

;; ;; Example medley for an anchor tag with id "foo", class "bar", and target "_blank" ;; (attribute "a#foo" :id) ;=> "foo" (attribute "a#foo" :class) ;=> "bar" (attribute "a#foo" :target) ;=> "_blank"

For the first element found with query `q`, return the value of the given `attribute`.

Examples:
=========

;;
;; Example medley for an anchor tag with id "foo", class "bar", and target "_blank"
;;
(attribute "a#foo" :id)     ;=> "foo"
(attribute "a#foo" :class)  ;=> "bar"
(attribute "a#foo" :target) ;=> "_blank"
sourceraw docstring

backclj

(back)
(back driver-or-n)
(back driver n)

Navigate back in the browser history, optionally n times.

Examples:

;; ;; Simple Example ;; (back)

;; ;; Specify number of times to go back ;; (back 2)

Navigate back in the browser history, optionally `n` times.

Examples:
=========

;;
;; Simple Example
;;
(back)

;;
;; Specify number of times to go back
;;
(back 2)
sourceraw docstring

clearclj

(clear q)
(clear driver q)

Clear the contents (the HTML value attribute) of the first form element found with query q.

Examples:

(clear "input.with-default-text")

Clear the contents (the HTML value attribute) of the first form element found with query `q`.

Examples:
=========

(clear "input.with-default-text")
sourceraw docstring

clickclj

(click q)
(click driver q)

Click the first element found with query q.

Examples:

(click "a#foo")

Click the first element found with query `q`.

Examples:
=========

(click "a#foo")
sourceraw docstring

closeclj

(close)
(close driver)

Close the browser. If multiple windows are open, this only closes the active window.

Examples:

(close)

Close the browser. If multiple windows are open, this only closes the active window.

Examples:
=========

(close)
sourceraw docstring

(cookie cookie-name)
(cookie driver cookie-name)

Return the cookie with name cookie-name. Returns a Cookie record which contains a :cookie field with the original Java object.

Examples:

(cookie "foo")

Return the cookie with name `cookie-name`. Returns a `Cookie` record which contains a `:cookie` field with the original Java object.

Examples:
=========

(cookie "foo")
sourceraw docstring

cookiesclj

(cookies)
(cookies driver)

Return a seq of all cookies in the browser session. Items are Cookie records, which themselves contain a :cookie field with the original Java objects.

Examples:

(cookies)

Return a seq of all cookies in the browser session. Items are `Cookie` records, which themselves contain a `:cookie` field with the original Java objects.

Examples:
=========

(cookies)
sourceraw docstring

css-finderclj

(css-finder q)
(css-finder driver q)

Given a CSS query q, return a lazy seq of the elements found by calling find-elements with by-css. If q is an Element, it is returned unchanged.

This function is used internally by the Taxi API as *finder*. See the documentation for set-finder! for examples of extending this function or creating your own custom finder function.

Given a CSS query `q`, return a lazy seq of the elements found by calling `find-elements` with `by-css`. If `q` is an `Element`, it is returned unchanged.

This function is used internally by the Taxi API as `*finder*`. See the documentation for `set-finder!` for examples of extending this function or creating your own custom finder function.
sourceraw docstring

current-urlclj

(current-url)
(current-url driver)

Return the current url of the browser.

Examples:

(current-url)

Return the current url of the browser.

Examples:
=========

(current-url)
sourceraw docstring

delete-all-cookiesclj

(delete-all-cookies)
(delete-all-cookies driver)

Delete all cookies from the browser session.

Examples:

(delete-all-cookies)

Delete all cookies from the browser session.

Examples:
=========

(delete-all-cookies)
sourceraw docstring

(delete-cookie name-or-obj)
(delete-cookie driver name-or-obj)

Provided the name of a cookie or a Cookie record itself, delete it from the browser session.

Examples:

;; ;; By name ;; (delete-cookie "foo")

;; ;; With Cookie record as returned by cookies or cookie functions ;; (delete-cookie a-cookie)

Provided the name of a cookie or a Cookie record itself, delete it from the browser session.

Examples:
=========

;;
;; By name
;;
(delete-cookie "foo")

;;
;; With `Cookie` record as returned by `cookies` or `cookie` functions
;;
(delete-cookie a-cookie)
sourceraw docstring

deselectclj

(deselect q)
(deselect driver q)

If the first form element found with query q is selected, click the element to deselect it. Otherwise, do nothing and just return the element found.

Examples:

(deselect "input.already-selected") ;=> click (deselect "input.not-selected") ;=> do nothing

If the first form element found with query `q` is selected, click the element to deselect it. Otherwise, do nothing and just return the element found.

Examples:
=========

(deselect "input.already-selected") ;=> click
(deselect "input.not-selected")     ;=> do nothing
sourceraw docstring

deselect-allclj

(deselect-all q)
(deselect-all driver q)

Deselect all options within the first select list found with query q.

Examples:

(deselect-all "#my-select-list")

Deselect all options within the first select list found with query `q`.

Examples:
=========

(deselect-all "#my-select-list")
sourceraw docstring

deselect-by-indexclj

(deselect-by-index q idx)
(deselect-by-index driver q idx)

Deselect the option element at index idx (zero-based) within the first select list found with query q.

Examples:

;; ;; Deselect by index, deselect 2nd element ;; (deselect-by-index "#my-select-list" 1)

Deselect the option element at index `idx` (zero-based) within the first select list found with query `q`.

Examples:
=========

;;
;; Deselect by index, deselect 2nd element
;;
(deselect-by-index "#my-select-list" 1)
sourceraw docstring

deselect-by-textclj

(deselect-by-text q text)
(deselect-by-text driver q text)

Deselect the option element with visible text text within the first select list found with query q.

Examples:

(deselect-by-text "#my-select-list" "Foo")

Deselect the option element with visible text `text` within the first select list found with query `q`.

Examples:
=========

(deselect-by-text "#my-select-list" "Foo")
sourceraw docstring

deselect-by-valueclj

(deselect-by-value q value)
(deselect-by-value driver q value)

Deselect the option element with value within the first select list found with query q.

Examples:

(deselect-by-value "#my-select-list" "foo")

Deselect the option element with `value` within the first select list found with query `q`.

Examples:
=========

(deselect-by-value "#my-select-list" "foo")
sourceraw docstring

deselect-optionclj

(deselect-option q attr-val)
(deselect-option driver q attr-val)

Deselect the option element matching attr-val within the first select list found with query q.

The attr-val can contain :index, :value, or :text keys to find the target option element. Index is the zero-based order of the option element in the list, value is the value of the HTML value attribute, and text is the visible text of the option element on the page.

Examples:

;; ;; By index, select 3rd option element ;; (deselect-option "#my-select-list" {:index 2})

;; ;; By value of option element ;; (deselect-option "#my-select-list" {:value "foo"})

;; ;; By visible text of option element ;; (deselect-option "#my-select-list" {:value "Foo"})

Deselect the option element matching `attr-val` within the first select list found with query `q`.

The `attr-val` can contain `:index`, `:value`, or `:text` keys to find the target option element. Index is the zero-based order of the option element in the list, value is the value of the HTML value attribute, and text is the visible text of the option element on the page.

Examples:
=========

;;
;; By index, select 3rd option element
;;
(deselect-option "#my-select-list" {:index 2})

;;
;; By value of option element
;;
(deselect-option "#my-select-list" {:value "foo"})

;;
;; By visible text of option element
;;
(deselect-option "#my-select-list" {:value "Foo"})
sourceraw docstring

dismissclj

(dismiss)
(dismiss driver)

Dismiss the alert popup dialog. Equivalent to pressing its 'Cancel' button.

Dismiss the alert popup dialog. Equivalent to pressing its 'Cancel' button.
sourceraw docstring

displayed?clj

(displayed? q)
(displayed? driver q)

Return true if the first element found with query q is visible on the page.

Examples:

(displayed? "div#container") ;=> true (displayed? "a.hidden") ;=> false

Return true if the first element found with query `q` is visible on the page.

Examples:
=========

(displayed? "div#container") ;=> true
(displayed? "a.hidden")      ;=> false
sourceraw docstring

drag-and-dropclj

(drag-and-drop qa qb)
(drag-and-drop driver qa qb)

Drag the first element found with query qa onto the first element found with query qb.

Examples:

;; ;; Drag div with id "draggable" onto div with id "droppable" ;; (drag-and-drop "#draggable" "#droppable")

Drag the first element found with query `qa` onto the first element found with query `qb`.

Examples:
=========

;;
;; Drag div with id "draggable" onto div with id "droppable"
;;
(drag-and-drop "#draggable" "#droppable")
sourceraw docstring

drag-and-drop-byclj

(drag-and-drop-by q x-y-map)
(drag-and-drop-by driver q x-y-map)

Drag the first element found with query q by :x pixels to the right and :y pixels down, passed in as a map like {:x 10, :y 10}. Values default to zero if excluded. Use negative numbers for :x and :y to move left or up respectively.

Examples:

;; ;; Drag a div with id "draggable" 20 pixels to the right ;; (drag-and-drop-by "#draggable" {:x 20})

;; ;; Drag a div with id "draggable" 10 pixels down ;; (drag-and-drop-by "#draggable" {:y 10})

;; ;; Drag a div with id "draggable" 15 pixels to the left and 5 pixels up ;; (drag-and-drop-by "#draggable" {:x -15, :y -5})

Drag the first element found with query `q` by `:x` pixels to the right and `:y` pixels down, passed in as a map like `{:x 10, :y 10}`. Values default to zero if excluded. Use negative numbers for `:x` and `:y` to move left or up respectively.

Examples:
=========

;;
;; Drag a div with id "draggable" 20 pixels to the right
;;
(drag-and-drop-by "#draggable" {:x 20})

;;
;; Drag a div with id "draggable" 10 pixels down
;;
(drag-and-drop-by "#draggable" {:y 10})

;;
;; Drag a div with id "draggable" 15 pixels to the left and 5 pixels up
;;
(drag-and-drop-by "#draggable" {:x -15, :y -5})
sourceraw docstring

elementclj

(element q)
(element driver q)

Given a query q, return the first element that the default finder function returns.

Examples:

;; ;; Simple Example ;; ;; Create a var that points to an element for later use. ;; (def login-link (element "a[href*='login']"))

;; ;; More useful example: composing actions on an element ;; ;; When threading actions together, it's more performant to thread an actual element, ;; than to thread simply the query string. Threading the query string makes clj-webdriver ;; locate the same element multiple times, while threading an actual element only ;; requires one lookup. ;; (-> (element "input#password") (input-text "my-password") submit)

Given a query `q`, return the first element that the default finder function returns.

Examples:
=========

;;
;; Simple Example
;;
;; Create a var that points to an element for later use.
;;
(def login-link (element "a[href*='login']"))

;;
;; More useful example: composing actions on an element
;;
;; When threading actions together, it's more performant to thread an actual element,
;; than to thread simply the query string. Threading the query string makes clj-webdriver
;; locate the same element multiple times, while threading an actual element only
;; requires one lookup.
;;
(-> (element "input#password")
  (input-text "my-password")
  submit)
sourceraw docstring

element-sizeclj

(element-size q)
(element-size driver q)

Return the size of the first element found with query q in pixels as a map of :width and :height.

Examples:

(size "div#container") ;=> {:width 960, :height 2000}

Return the size of the first element found with query `q` in pixels as a map of `:width` and `:height`.

Examples:
=========

(size "div#container") ;=> {:width 960, :height 2000} 
sourceraw docstring

elementsclj

(elements q)
(elements driver q)

Given a query q, return the elements that the default finder function returns.

Examples:

;; ;; Simple Example ;; ;; Save a seq of anchor tags (links) for later. ;; (def target-elements (elements "a"))

Given a query `q`, return the elements that the default finder function returns.

Examples:
=========

;;
;; Simple Example
;;
;; Save a seq of anchor tags (links) for later.
;;
(def target-elements (elements "a"))
sourceraw docstring

enabled?clj

(enabled? q)
(enabled? driver q)

Return true if the first form element found with query q is enabled (not disabled).

Examples:

(enabled? "input") ;=> true (enabled? "input[disabled='disabled']") ;=> false

Return true if the first form element found with query `q` is enabled (not disabled).

Examples:
=========

(enabled? "input")                      ;=> true
(enabled? "input[disabled='disabled']") ;=> false
sourceraw docstring

execute-scriptclj

(execute-script js)
(execute-script driver-or-js js-or-args)
(execute-script driver js js-args)

Execute the JavaScript code js with arguments js-args which must be passed in as a vector (for arity reasons).

Within the script, use document to refer to the current document. Note that local variables will not be available once the script has finished executing, though global variables will persist.

If the script has a return value (i.e. if the script contains a return statement), then the following steps will be taken:

  • For an HTML element, this method returns a WebElement
  • For a decimal, a Double is returned
  • For a non-decimal number, a Long is returned
  • For a boolean, a Boolean is returned
  • For all other cases, a String is returned.
  • For an array, return a List<Object> with each object following the rules above. We support nested lists.
  • Unless the value is null or there is no return value, in which null is returned.

Arguments must be a number, a boolean, a String, WebElement, or a List of any combination of the above. An exception will be thrown if the arguments do not meet these criteria. The arguments will be made available to the JavaScript via the 'arguments' magic variable, as if the function were called via 'Function.apply'

See http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/remote/RemoteWebDriver.html#executeScript(java.lang.String, java.lang.Object...) for full details.

Examples:

;; ;; Set a global variable ;; (execute-script "window.document.title = 'asdf'")

;; ;; Return an element. Note that this currently returns a raw WebElement Java object. ;; (execute-script "var myElement = document.getElementById('elementId'); return myElement;")

Execute the JavaScript code `js` with arguments `js-args` which must be passed in as a vector (for arity reasons).

Within the script, use document to refer to the current document. Note that local variables will not be available once the script has finished executing, though global variables will persist.

If the script has a return value (i.e. if the script contains a return statement), then the following steps will be taken:

 * For an HTML element, this method returns a WebElement
 * For a decimal, a Double is returned
 * For a non-decimal number, a Long is returned
 * For a boolean, a Boolean is returned
 * For all other cases, a String is returned.
 * For an array, return a List<Object> with each object following the rules above. We support nested lists.
 * Unless the value is null or there is no return value, in which null is returned.

Arguments must be a number, a boolean, a String, WebElement, or a List of any combination of the above. An exception will be thrown if the arguments do not meet these criteria. The arguments will be made available to the JavaScript via the 'arguments' magic variable, as if the function were called via 'Function.apply'

See http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/remote/RemoteWebDriver.html#executeScript(java.lang.String, java.lang.Object...) for full details.

Examples:
=========

;;
;; Set a global variable
;;
(execute-script "window.document.title = 'asdf'")

;;
;; Return an element. Note that this currently returns a raw WebElement Java object.
;;
(execute-script "var myElement = document.getElementById('elementId'); return myElement;")
sourceraw docstring

exists?clj

(exists? q)
(exists? driver q)

Return true if the first element found with query q exists on the current page in the browser.

Examples:

(exists? "a#foo") ;=> true (exists? "footer") ;=> false

Return true if the first element found with query `q` exists on the current page in the browser.

Examples:
=========

(exists? "a#foo")   ;=> true
(exists? "footer")  ;=> false
sourceraw docstring

find-elementclj

(find-element attr-val)
(find-element driver attr-val)

Return first Element record that matches the given attr-val. Prefer the default behavior of element when possible.

Whereas the element function uses a query q with the default finder function, this function requires an attr-val parameter which is either a map or a vector of maps with special semantics for finding elements on the page.

The attr-val map can consist of one or more of the following:

  • The key :css or :xpath and a query value (e.g., {:css "a.external"})
  • The key :tag and an HTML tag (e.g., {:tag :a})
  • An HTML element attribute and its value (e.g., {:class "external"})
  • A 'meta' tag :button*, :radio, :checkbox, :textfield, :password, :filefield (e.g., {:tag :button*})
  • The key :index and the zero-based index (order) of the target element on the page (e.g., {:index 2} retrieves the third element that matches)
  • A vector of attr-val maps like the above, representing a hierarchical query (auto-generates XPath)

Examples:

;; ;; Medley of possibilities ;; (find-element {:css "a.foo"}) (find-element {:xpath "//a[@class='foo']"}) (find-element {:tag :a, :text "Login"}) (find-element {:tag :a, :index 4}) ;; 5th anchor tag (find-element {:tag :button*, :class "foo"}) (find-element {:tag :radio, :class "choice"}) (find-element [{:tag :div, :id "container"}, {:tag :a, :class "external"}])

Return first `Element` record that matches the given `attr-val`. Prefer the default behavior of `element` when possible.

Whereas the `element` function uses a query `q` with the default finder function, this function requires an `attr-val` parameter which is either a map or a vector of maps with special semantics for finding elements on the page.

The `attr-val` map can consist of one or more of the following:

 * The key `:css` or `:xpath` and a query value (e.g., `{:css "a.external"}`)
 * The key `:tag` and an HTML tag (e.g., `{:tag :a}`)
 * An HTML element attribute and its value (e.g., `{:class "external"}`)
 * A 'meta' tag `:button*`, `:radio`, `:checkbox`, `:textfield`, `:password`, `:filefield` (e.g., `{:tag :button*}`)
 * The key `:index` and the zero-based index (order) of the target element on the page (e.g., `{:index 2}` retrieves the third element that matches)
 * A vector of attr-val maps like the above, representing a hierarchical query (auto-generates XPath)

Examples:
=========

;;
;; Medley of possibilities
;;
(find-element {:css "a.foo"})
(find-element {:xpath "//a[@class='foo']"})
(find-element {:tag :a, :text "Login"})
(find-element {:tag :a, :index 4}) ;; 5th anchor tag
(find-element {:tag :button*, :class "foo"})
(find-element {:tag :radio, :class "choice"})
(find-element [{:tag :div, :id "container"},
               {:tag :a, :class "external"}])
sourceraw docstring

find-element-underclj

(find-element-under q-parent attr-val)
(find-element-under driver q-parent attr-val)

Find the first element that is a child of the element found with query q-parent, using the given attr-val. If q-parent is an Element, it will be used as-is. The attr-val can either be a find-element-style map of attributes and values, or a by-clause (by-tag, by-class, etc.)

Examples:

;; ;; Example using map, which generates a (by-xpath ...) form ;; (find-element-under "div#container" {:tag :a, :id "foo"})

;; ;; Example using by-clause, find an element with id "foo" within a div with id "container" ;; (find-element-under "div#container" (core/by-id "foo")

Find the first element that is a child of the element found with query `q-parent`, using the given `attr-val`. If `q-parent` is an `Element`, it will be used as-is. The `attr-val` can either be a find-element-style map of attributes and values, or a by-clause (`by-tag`, `by-class`, etc.)

Examples:
=========

;;
;; Example using map, which generates a (by-xpath ...) form
;;
(find-element-under  "div#container" {:tag :a, :id "foo"})

;;
;; Example using by-clause, find an element with id "foo" within a div with id "container"
;;
(find-element-under "div#container" (core/by-id "foo")
sourceraw docstring

find-elementsclj

(find-elements attr-val)
(find-elements driver attr-val)

Return Element records that match the given attr-val. Prefer the default behavior of elements when possible.

Whereas the elements function uses a query q with the default finder function, this function requires an attr-val parameter which is either a map or a vector of maps with special semantics for finding elements on the page.

The attr-val map can consist of one or more of the following:

  • The key :css or :xpath and a query value (e.g., {:css "a.external"})
  • The key :tag and an HTML tag (e.g., {:tag :a})
  • An HTML element attribute and its value (e.g., {:class "external"})
  • A 'meta' tag :button*, :radio, :checkbox, :textfield, :password, :filefield (e.g., {:tag :button*})
  • The key :index and the zero-based index (order) of the target element on the page (e.g., {:index 2} retrieves the third element that matches)
  • A vector of attr-val maps like the above, representing a hierarchical query (auto-generates XPath)

Examples:

;; ;; Medley of possibilities ;; (find-elements {:css "a.foo"}) (find-elements {:xpath "//a[@class='foo']"}) (find-elements {:tag :a, :text "Login"}) (find-elements {:tag :a, :index 4}) ;; 5th anchor tag (find-elements {:tag :button*, :class "foo"}) (find-elements {:tag :radio, :class "choice"}) (find-elements [{:tag :div, :id "container"}, {:tag :a, :class "external"}])

Return `Element` records that match the given `attr-val`. Prefer the default behavior of `elements` when possible.

Whereas the `elements` function uses a query `q` with the default finder function, this function requires an `attr-val` parameter which is either a map or a vector of maps with special semantics for finding elements on the page.

The `attr-val` map can consist of one or more of the following:

 * The key `:css` or `:xpath` and a query value (e.g., `{:css "a.external"}`)
 * The key `:tag` and an HTML tag (e.g., `{:tag :a}`)
 * An HTML element attribute and its value (e.g., `{:class "external"}`)
 * A 'meta' tag `:button*`, `:radio`, `:checkbox`, `:textfield`, `:password`, `:filefield` (e.g., `{:tag :button*}`)
 * The key `:index` and the zero-based index (order) of the target element on the page (e.g., `{:index 2}` retrieves the third element that matches)
 * A vector of attr-val maps like the above, representing a hierarchical query (auto-generates XPath)

Examples:
=========

;;
;; Medley of possibilities
;;
(find-elements {:css "a.foo"})
(find-elements {:xpath "//a[@class='foo']"})
(find-elements {:tag :a, :text "Login"})
(find-elements {:tag :a, :index 4}) ;; 5th anchor tag
(find-elements {:tag :button*, :class "foo"})
(find-elements {:tag :radio, :class "choice"})
(find-elements [{:tag :div, :id "container"},
                {:tag :a, :class "external"}])
sourceraw docstring

find-elements-underclj

(find-elements-under q-parent attr-val)
(find-elements-under driver q-parent attr-val)

Find the elements that are children of the element found with query q-parent, using the given attr-val. If q-parent is an Element, it will be used as-is. The attr-val can either be a find-element-style map of attributes and values, or a by-clause (by-tag, by-class, etc.)

Examples:

;; ;; Example using a map ;; (find-elements-under "div#container" {:tag :a, :id "foo"})

;; ;; Example using by-clause, find an element with id "foo" within a div with id "container" ;; (find-elements-under "div#container" (core/by-id "foo")

Find the elements that are children of the element found with query `q-parent`, using the given `attr-val`. If `q-parent` is an `Element`, it will be used as-is. The `attr-val` can either be a find-element-style map of attributes and values, or a by-clause (`by-tag`, `by-class`, etc.)


Examples:
=========

;;
;; Example using a map
;;
(find-elements-under  "div#container" {:tag :a, :id "foo"})

;;
;; Example using by-clause, find an element with id "foo" within a div with id "container"
;;
(find-elements-under "div#container" (core/by-id "foo")
sourceraw docstring

find-table-cellclj

(find-table-cell table-q coords)
(find-table-cell driver table-q coords)

Within the table found with query table-q, return the table cell at coordinates coords. The top-left cell has coordinates [0 0].

Examples:

;; ;; Simple example, find 2nd cell on 2nd row from top ;; (find-table-cell "table#my-table" [1 1])

Within the table found with query `table-q`, return the table cell at coordinates `coords`. The top-left cell has coordinates `[0 0]`.

Examples:
=========

;;
;; Simple example, find 2nd cell on 2nd row from top
;;
(find-table-cell "table#my-table" [1 1])
sourceraw docstring

find-table-rowclj

(find-table-row table-q row)
(find-table-row driver table-q row)

Within the table found with query table-q, return a seq of all cells at row number row. The top-most row is row 0 (zero-based index).

Examples:

;; ;; Simple example, return cells in second row ;; (find-table-row "table#my-table" 1)

Within the table found with query `table-q`, return a seq of all cells at row number `row`. The top-most row is row `0` (zero-based index).

Examples:
=========

;;
;; Simple example, return cells in second row
;;
(find-table-row "table#my-table" 1)
sourceraw docstring

find-windowclj

(find-window attr-val)
(find-window driver attr-val)

Return the first Window record that matches the given attr-val map.

Attributes can be anything in a Window record (:title or :url) or you can pass an :index key and a number value to select a window by its open order.

Examples:

;; ;; By name ;; (find-window {:title "Window Title"})

;; ;; By URL ;; (find-window {:url "http://example.com/test-page"})

;; ;; By index ;; (find-window {:index 2})

Return the first `Window` record that matches the given `attr-val` map.

Attributes can be anything in a `Window` record (`:title` or `:url`) or you can pass an `:index` key and a number value to select a window by its open order.

Examples:
=========

;;
;; By name
;;
(find-window {:title "Window Title"})

;;
;; By URL
;;
(find-window {:url "http://example.com/test-page"})

;;
;; By index
;;
(find-window {:index 2})
sourceraw docstring

find-windowsclj

(find-windows attr-val)
(find-windows driver attr-val)

Return all Window records that match the given attr-val map.

Attributes can be anything in a Window record (:title or :url) or you can pass an :index key and a number value to select a window by its open order.

Examples:

;; ;; By name ;; (find-windows {:title "Window Title"})

;; ;; By URL ;; (find-windows {:url "http://example.com/test-page"})

;; ;; By index ;; (find-windows {:index 2})

Return all `Window` records that match the given `attr-val` map.

Attributes can be anything in a `Window` record (`:title` or `:url`) or you can pass an `:index` key and a number value to select a window by its open order.

Examples:
=========

;;
;; By name
;;
(find-windows {:title "Window Title"})

;;
;; By URL
;;
(find-windows {:url "http://example.com/test-page"})

;;
;; By index
;;
(find-windows {:index 2})
sourceraw docstring

flashclj

(flash q)
(flash driver q)

Flash the background color of the first element found with query q.

Examples:

(flash "a.hard-to-see")

Flash the background color of the first element found with query `q`.

Examples:
=========

(flash "a.hard-to-see")
sourceraw docstring

focusclj

(focus q)
(focus driver q)

Explicitly give the first element found with query q focus on the page.

Examples:

(focus "input.next-element")

Explicitly give the first element found with query `q` focus on the page.

Examples:
=========

(focus "input.next-element")
sourceraw docstring

forwardclj

(forward)
(forward driver-or-n)
(forward driver n)

Navigate forward in the browser history.

Examples:

;; ;; Simple Example ;; (forward)

;; ;; Specify number of times to go forward ;; (forward 2)

Navigate forward in the browser history.

Examples:
=========

;;
;; Simple Example
;;
(forward)

;;
;; Specify number of times to go forward
;;
(forward 2)
sourceraw docstring

get-urlclj

(get-url url)
(get-url driver url)

Navigate the browser to url.

Examples:

;; ;; Simple Example ;; (get-url "https://github.com")

;; ;; Custom function for building URL's from a base url ;; (defn go [path] (let [base-url "http://example.com/"] (get-url (str base-url path)))) ;; (go "test-page") would navigate to "http://example.com/test-page"

Navigate the browser to `url`.

Examples:
=========

;;
;; Simple Example
;;
(get-url "https://github.com")

;;
;; Custom function for building URL's from a base url
;;
(defn go
 [path]
 (let [base-url "http://example.com/"]
   (get-url (str base-url path))))
;; (go "test-page") would navigate to "http://example.com/test-page"
sourceraw docstring

htmlclj

(html q)
(html driver q)

Return the inner html of the first element found with query q.

Examples:

(html "div.with-interesting-html")

Return the inner html of the first element found with query `q`.

Examples:
=========

(html "div.with-interesting-html")
sourceraw docstring

implicit-waitclj

(implicit-wait timeout)
(implicit-wait driver timeout)

Set the global timeout that the browser should wait when attempting to find elements on the page, before timing out with an exception.

Examples:

;; ;; Simple example (taken from unit tests) ;; ;; Set implicit timeout (global) to 3 seconds, then execute JavaScript with a ;; noticeable delay to prove that it works ;; (implicit-wait 3000) (execute-script "setTimeout(function () { window.document.body.innerHTML = '<div id='test'>hi!</div>'}, 1000)")

Set the global `timeout` that the browser should wait when attempting to find elements on the page, before timing out with an exception.

Examples:
=========

;;
;; Simple example (taken from unit tests)
;;
;; Set implicit timeout (global) to 3 seconds, then execute JavaScript with a
;; noticeable delay to prove that it works
;;
(implicit-wait 3000)
(execute-script "setTimeout(function () { window.document.body.innerHTML = '<div id='test'>hi!</div>'}, 1000)")
sourceraw docstring

input-textclj

(input-text q s)
(input-text driver q s)

Type the string s into the first form element found with query q.

Examples:

(input-text "input#login_field" "semperos")

Type the string `s` into the first form element found with query `q`.

Examples:
=========

(input-text "input#login_field" "semperos")
sourceraw docstring

intersects?clj

(intersects? qa qb)
(intersects? driver qa qb)

Return true if the first element found with query qa intersects with the first element found with query qb.

Examples:

(intersect? "#login" "#login_field") ;=> true (intersect? "#login_field" "#password") ;=> false

Return true if the first element found with query `qa` intersects with the first element found with query `qb`.

Examples:
=========

(intersect? "#login" "#login_field")    ;=> true
(intersect? "#login_field" "#password") ;=> false
sourceraw docstring

locationclj

(location q)
(location driver q)

Return a map of :x and :y coordinates for the first element found with query q.

Examples:

(location "a#foo") ;=> {:x 240, :y 300}

Return a map of `:x` and `:y` coordinates for the first element found with query `q`.

Examples:
=========

(location "a#foo") ;=> {:x 240, :y 300}
sourceraw docstring

location-once-visibleclj

(location-once-visible q)
(location-once-visible driver q)

Return a map of :x and :y coordinates for the first element found with query q once the page has been scrolled enough to be visible in the viewport.

Examples:

(location-once-visible "a#foo") ;=> {:x 240, :y 300}

Return a map of `:x` and `:y` coordinates for the first element found with query `q` once the page has been scrolled enough to be visible in the viewport.

Examples:
=========

(location-once-visible "a#foo") ;=> {:x 240, :y 300}
sourceraw docstring

multiple?clj

(multiple? q)
(multiple? driver q)

Return true if the first select list found with query q allows multiple selections.

Examples:

(multiple? "select.multiple") ;=> true (multiple? "select.not-multiple") ;=> false

Return true if the first select list found with query `q` allows multiple selections.

Examples:
=========

(multiple? "select.multiple")     ;=> true
(multiple? "select.not-multiple") ;=> false 
sourceraw docstring

new-driverclj

(new-driver browser-spec)

Alias of clj-webdriver.core/new-driver: 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.

Alias of clj-webdriver.core/new-driver:
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.
sourceraw docstring

optionsclj

(options q)
(options driver q)

Return all option elements within the first select list found with query q.

Examples:

(options "#my-select-list")

Return all option elements within the first select list found with query `q`.

Examples:
=========

(options "#my-select-list")
sourceraw docstring

other-windowsclj

(other-windows)
(other-windows driver)

Return a Window for all open windows except the active one.

Examples:

(other-windows)

Return a `Window` for all open windows except the active one.

Examples:
=========

(other-windows)
sourceraw docstring

page-sourceclj

(page-source)
(page-source driver)

Return the source code of the current page in the browser.

Examples:

;; ;; Simple Example ;; (page-source)

;; ;; Do something with the HTML ;; ;; Selenium-WebDriver will instantiate a Java object for every element you query ;; or interact with, so if you have huge pages or need to do heavy-duty DOM ;; inspection or traversal, it could be more performant to do that "offline". ;; (let [source (page-source)] ;; do hard-core parsing and manipulation here )

Return the source code of the current page in the browser.

Examples:
=========

;;
;; Simple Example
;;
(page-source)

;;
;; Do something with the HTML
;;
;; Selenium-WebDriver will instantiate a Java object for every element you query
;; or interact with, so if you have huge pages or need to do heavy-duty DOM
;; inspection or traversal, it could be more performant to do that "offline".
;;
(let [source (page-source)]
  ;; do hard-core parsing and manipulation here
  )
sourceraw docstring

present?clj

(present? q)
(present? driver q)

Return true if the first element found with query q both exists and is visible on the page.

Examples:

(present? "div#container") ;=> true (present? "a#skip-to-navigation") ;=> false

Return true if the first element found with query `q` both exists and is visible on the page.

Examples:
=========

(present? "div#container")        ;=> true
(present? "a#skip-to-navigation") ;=> false
sourceraw docstring

quick-fillclj

(quick-fill & query-action-maps)

A utility for filling out multiple fields in a form in one go. Returns all the affected elements (if you want a list of unique elements, pass the results through the distinct function in clojure.core).

query-action-maps - a seq of maps of queries to actions (queries find HTML elements, actions are fn's that act on them)

Note that an "action" that is just a String will be interpreted as a call to input-text with that String for the target text field.

Examples:

(quick-fill {"#first_name" "Rich"} {"a.foo" click})

A utility for filling out multiple fields in a form in one go. Returns all the affected elements (if you want a list of unique elements, pass the results through the `distinct` function in clojure.core).

`query-action-maps`   - a seq of maps of queries to actions (queries find HTML elements, actions are fn's that act on them)

Note that an "action" that is just a String will be interpreted as a call to `input-text` with that String for the target text field.

Examples:
=========

(quick-fill {"#first_name" "Rich"}
            {"a.foo" click})
sourceraw docstring

quick-fill-submitclj

(quick-fill-submit & query-action-maps)

A utility for filling out multiple fields in a form in one go. Always returns nil instead of the affected elements, since on submit all of the elements will be void.

query-action-maps - a seq of maps of queries to actions (queries find HTML elements, actions are fn's that act on them)

Note that an "action" that is just a String will be interpreted as a call to input-text with that String for the target text field.

Examples:

(quick-fill {"#first_name" "Rich"} {"a.foo" click})

A utility for filling out multiple fields in a form in one go. Always returns nil instead of the affected elements, since on submit all of the elements will be void.

`query-action-maps`   - a seq of maps of queries to actions (queries find HTML elements, actions are fn's that act on them)

Note that an "action" that is just a String will be interpreted as a call to `input-text` with that String for the target text field.

Examples:
=========

(quick-fill {"#first_name" "Rich"}
            {"a.foo" click})
sourceraw docstring

quitclj

(quit)
(quit driver)

Quit the browser completely, including all open windows.

Examples:

(quit)

Quit the browser completely, including all open windows.

Examples:
=========

(quit)
sourceraw docstring

refreshclj

(refresh)
(refresh driver)

Refresh the current page in the browser. Note that all references to elements will become "stale" and unusable after a page refresh.

Examples:

(refresh)

Refresh the current page in the browser. Note that all references to elements will become "stale" and unusable after a page refresh.

Examples:
=========

(refresh)
sourceraw docstring

selectclj

(select q)
(select driver q)

If the first form element found with query q is not selected, click the element to select it. Otherwise, do nothing and just return the element found.

Examples:

(select "input.already-selected") ;=> do nothing (select "input.not-selected") ;=> click

If the first form element found with query `q` is not selected, click the element to select it. Otherwise, do nothing and just return the element found.

Examples:
=========

(select "input.already-selected") ;=> do nothing
(select "input.not-selected")     ;=> click
sourceraw docstring

select-allclj

(select-all q)
(select-all driver q)

Select all options within the first select list found with query q.

Examples:

(deselect-all "#my-select-list")

Select all options within the first select list found with query `q`.

Examples:
=========

(deselect-all "#my-select-list")
sourceraw docstring

select-by-indexclj

(select-by-index q idx)
(select-by-index driver q idx)

Select the option element at index idx (zero-based) within the first select list found with query q.

Examples:

;; ;; Select by index, select 2nd element ;; (select-by-index "#my-select-list" 1)

Select the option element at index `idx` (zero-based) within the first select list found with query `q`.

Examples:
=========

;;
;; Select by index, select 2nd element
;;
(select-by-index "#my-select-list" 1)
sourceraw docstring

select-by-textclj

(select-by-text q text)
(select-by-text driver q text)

Select the option element with visible text text within the first select list found with query q.

Examples:

(select-by-text "#my-select-list" "foo")

Select the option element with visible text `text` within the first select list found with query `q`.

Examples:
=========

(select-by-text "#my-select-list" "foo")
sourceraw docstring

select-by-valueclj

(select-by-value q value)
(select-by-value driver q value)

Select the option element with value within the first select list found with query q.

Examples:

(select-by-value "#my-select-list" "foo")

Select the option element with `value` within the first select list found with query `q`.

Examples:
=========

(select-by-value "#my-select-list" "foo")
sourceraw docstring

select-optionclj

(select-option q attr-val)
(select-option driver q attr-val)

Select the option element matching attr-val within the first select list found with query q.

The attr-val can contain :index, :value, or :text keys to find the target option element. Index is the zero-based order of the option element in the list, value is the value of the HTML value attribute, and text is the visible text of the option element on the page.

Examples:

;; ;; By index, select 3rd option element ;; (select-option "#my-select-list" {:index 2})

;; ;; By value of option element ;; (select-option "#my-select-list" {:value "foo"})

;; ;; By visible text of option element ;; (select-option "#my-select-list" {:value "Foo"})

Select the option element matching `attr-val` within the first select list found with query `q`.

The `attr-val` can contain `:index`, `:value`, or `:text` keys to find the target option element. Index is the zero-based order of the option element in the list, value is the value of the HTML value attribute, and text is the visible text of the option element on the page.

Examples:
=========

;;
;; By index, select 3rd option element
;;
(select-option "#my-select-list" {:index 2})

;;
;; By value of option element
;;
(select-option "#my-select-list" {:value "foo"})

;;
;; By visible text of option element
;;
(select-option "#my-select-list" {:value "Foo"})
sourceraw docstring

selected-optionsclj

(selected-options q)
(selected-options driver q)

Return all selected option elements within the first select list found with query q.

Examples:

(selected-options "#my-select-list")

Return all selected option elements within the first select list found with query `q`.

Examples:
=========

(selected-options "#my-select-list")
sourceraw docstring

selected?clj

(selected? q)
(selected? driver q)

Return true if the first element found with the query q is selected (works for radio buttons, checkboxes, and option tags within select lists).

Examples:

(selected? "input[type='radio'][value='foo']") ;=> true (selected? "option[value='foo']") ;=> false

Return true if the first element found with the query `q` is selected (works for radio buttons, checkboxes, and option tags within select lists).

Examples:
=========

(selected? "input[type='radio'][value='foo']") ;=> true
(selected? "option[value='foo']")              ;=> false 
sourceraw docstring

send-keysclj

(send-keys q s)
(send-keys driver q s)

Type the string s into the first form element found with query q.

Examples:

(input-text "input#login_field" "semperos")

Type the string `s` into the first form element found with query `q`.

Examples:
=========

(input-text "input#login_field" "semperos")
sourceraw docstring

set-driver!clj

(set-driver! browser-spec)
(set-driver! browser-spec url)

Set a default Driver for this thread, optionally sending it to a starting url.

Available browsers are :firefox, :chrome, :ie, :opera, :phantomjs and :htmlunit.

Examples:

;; ;; Simple example ;; (set-driver! {:browser :firefox})

;; ;; Full example ;; (set-driver! {:browser :firefox :cache-spec {:strategy :basic, :args [{}], :include [ (fn [element] (= (attribute element :class) "external")) {:css "ol#pages"}]}

;; ;; Use existing Driver record ;; (set-driver! a-driver)

Set a default `Driver` for this thread, optionally sending it to a starting `url`.

Available browsers are `:firefox`, `:chrome`, `:ie`, `:opera`, `:phantomjs` and `:htmlunit`.

Examples:
=========

;;
;; Simple example
;;
(set-driver! {:browser :firefox})

;;
;; Full example
;;
(set-driver! {:browser :firefox
              :cache-spec {:strategy :basic,
                           :args [{}],
                           :include [ (fn [element] (= (attribute element :class) "external"))
                                      {:css "ol#pages"}]}

;;
;; Use existing Driver record
;;
(set-driver! a-driver)
sourceraw docstring

set-finder!clj

(set-finder! finder-fn)

Set a default finder function, which will be used with all q parameters in functions that require an Element.

Examples:

;; ;; Simple example ;; (set-finder! xpath-finder)

;; ;; Derivative finder function ;; ;; Takes the query string and always prepends "div#container ", which would be ;; useful in situations where you know you're always inside that particular div. ;; (Note that this same functionality is provided by find-element-under, but ;; you get the idea.) ;; (set-finder! (fn [q] (if (element-like? q) q (css-finder (str "div#container " q)))))

;; ;; Custom finder function ;; ;; If you want to easily switch between using CSS and XPath (e.g., because ;; XPath has the text() function for which no CSS equivalent exists), then ;; you could write something like this, where q would become either the map ;; {:css "query"} or {:xpath "query"} instead of just a string. ;; (set-finder! (fn [q] (if (element-like? q) q (case (first (keys q)) :css (core/find-elements-by driver (by-css (first (values q)))) :xpath (core/find-elements-by driver (by-xpath (first (values q))))))))

;; ;; (Note: This last example is written to show how to use the lowest-level functions ;; find-elements-by, by-css and by-xpath. The maps {:css "query"} and ;; {:xpath "query"} are themselves acceptable arguments to the find-elements, ;; function, so that function could have been used instead without the case statement.) ;;

Set a default finder function, which will be used with all `q` parameters in functions that require an Element.

Examples:
=========

;;
;; Simple example
;;
(set-finder! xpath-finder)

;;
;; Derivative finder function
;;
;; Takes the query string and always prepends "div#container ", which would be
;; useful in situations where you know you're always inside that particular div.
;; (Note that this same functionality is provided by `find-element-under`, but
;; you get the idea.)
;;
(set-finder! (fn [q]
               (if (element-like? q)
                 q
                 (css-finder (str "div#container " q)))))

;;
;; Custom finder function
;;
;; If you want to easily switch between using CSS and XPath (e.g., because
;; XPath has the text() function for which no CSS equivalent exists), then
;; you could write something like this, where `q` would become either the map
;; {:css "query"} or {:xpath "query"} instead of just a string.
;;
(set-finder! (fn [q]
               (if (element-like? q)
                 q
                 (case (first (keys q))
                   :css   (core/find-elements-by *driver* (by-css (first (values q))))
                   :xpath (core/find-elements-by *driver* (by-xpath (first (values q))))))))

;;
;; (Note: This last example is written to show how to use the lowest-level functions
;; `find-elements-by`, `by-css` and `by-xpath`. The maps `{:css "query"}` and
;; `{:xpath "query"}` are themselves acceptable arguments to the `find-elements`,
;; function, so that function could have been used instead without the `case` statement.)
;;
sourceraw docstring

submitclj

(submit q)
(submit driver q)

Submit the form that the first form element found with query q belongs to (this is equivalent to pressing ENTER in a text field while filling out a form).

Examples:

(submit "input#password")

Submit the form that the first form element found with query `q` belongs to (this is equivalent to pressing ENTER in a text field while filling out a form).

Examples:
=========

(submit "input#password")
sourceraw docstring

switch-to-activeclj

(switch-to-active)
(switch-to-active driver)

Switch to the page element that currently has focus, or to the body if this cannot be detected.

Examples:

(switch-to-active)

Switch to the page element that currently has focus, or to the body if this cannot be detected.

Examples:
=========

(switch-to-active)
sourceraw docstring

switch-to-defaultclj

(switch-to-default)
(switch-to-default driver)

Switch focus to the first first frame of the page, or the main document if the page contains iframes.

Examples:

(switch-to-default)

Switch focus to the first first frame of the page, or the main document if the page contains iframes.

Examples:
=========

(switch-to-default)
sourceraw docstring

switch-to-frameclj

(switch-to-frame frame-q)
(switch-to-frame driver frame-q)

Switch focus to the frame specified by frame-q, which is a standard Taxi element query or an integer for the order (zero-based index) of the frame on the page.

Examples:

(switch-to-frame "#target-frame") (switch-to-frame 1)

Switch focus to the frame specified by `frame-q`, which is a standard Taxi element query or an integer for the order (zero-based index) of the frame on the page.

Examples:
=========

(switch-to-frame "#target-frame")
(switch-to-frame 1)
sourceraw docstring

switch-to-other-windowclj

(switch-to-other-window)
(switch-to-other-window driver)

If two windows are open, switch focus to the other.

Examples:

(switch-to-other-window)

If two windows are open, switch focus to the other.

Examples:
=========

(switch-to-other-window)
sourceraw docstring

switch-to-windowclj

(switch-to-window window)
(switch-to-window driver window)

Switch focus to the window for the given one of the following:

  • A string representing the target window name (as seen in the application titlebar)
  • A number representing the index (order) of the target window
  • A Window record

Examples:

;; ;; By name ;; (switch-to-window "Name Of Window")

;; ;; By index (order), open the 3rd window ;; (switch-to-window 2)

;; ;; Passing a Window record directly (as returned by the window function) ;; (switch-to-window a-window-record)

Switch focus to the window for the given one of the following:

 * A string representing the target window name (as seen in the application titlebar)
 * A number representing the index (order) of the target window
 * A `Window` record

Examples:
=========

;;
;; By name
;;
(switch-to-window "Name Of Window")

;;
;; By index (order), open the 3rd window
;;
(switch-to-window 2)

;;
;; Passing a `Window` record directly (as returned by the `window` function)
;;
(switch-to-window a-window-record)
sourceraw docstring

tagclj

(tag q)
(tag driver q)

Return the HTML tag for the first element found with query q.

Examples:

(tag "#foo") ;=> "a"

Return the HTML tag for the first element found with query `q`.

Examples:
=========

(tag "#foo") ;=> "a"
sourceraw docstring

take-screenshotclj

(take-screenshot)
(take-screenshot format)
(take-screenshot format destination)
(take-screenshot driver format destination)

Take a screenshot of the browser's current page, optionally specifying the format (:file, :base64, or :bytes) and the destination (something that clojure.java.io/file will accept).

Examples:

;; ;; Simple Example ;; ;; Return screenshot as file object ;; (take-screenshot :file)

;; ;; Specify a default destination for the file object ;; (take-screenshot :file "/path/to/save/screenshot.png")

Take a screenshot of the browser's current page, optionally specifying the format (`:file`, `:base64`, or `:bytes`) and the `destination` (something that `clojure.java.io/file` will accept).

Examples:
=========

;;
;; Simple Example
;;
;; Return screenshot as file object
;;
(take-screenshot :file)

;;
;; Specify a default destination for the file object
;;
(take-screenshot :file "/path/to/save/screenshot.png")
sourceraw docstring

textclj

(text q)
(text driver q)

Return the text within the first element found with query q.

Examples:

(text "#message") ;=> "An error occurred."

Return the text within the first element found with query `q`.

Examples:
=========

(text "#message") ;=> "An error occurred."
sourceraw docstring

titleclj

(title)
(title driver)

Return the title of the current page in the browser.

Examples:

(title)

Return the title of the current page in the browser.

Examples:
=========

(title)
sourceraw docstring

toclj

(to url)
(to driver url)

Navigate the browser to url.

Examples:

;; ;; Simple Example ;; (to "https://github.com")

;; ;; Custom function for building URL's from a base url ;; (defn go [path] (let [base-url "http://example.com/"] (to (str base-url path)))) ;; (go "test-page") would navigate to "http://example.com/test-page"

Navigate the browser to `url`.

Examples:
=========

;;
;; Simple Example
;;
(to "https://github.com")

;;
;; Custom function for building URL's from a base url
;;
(defn go
 [path]
 (let [base-url "http://example.com/"]
   (to (str base-url path))))
;; (go "test-page") would navigate to "http://example.com/test-page"
sourceraw docstring

toggleclj

(toggle q)
(toggle driver q)

Toggle is a synonym for click. Click the first element found with query q.

Examples:

(toggle "input[type='checkbox'][value='foo']")

Toggle is a synonym for click. Click the first element found with query `q`.

Examples:
=========

(toggle "input[type='checkbox'][value='foo']")
sourceraw docstring

valueclj

(value q)
(value driver q)

Return the value of the HTML value attribute for the first element found with query q. The is identical to (attribute q :value)

Examples:

(value "#my-button") ;=> "submit"

Return the value of the HTML value attribute for the first element found with query `q`. The is identical to `(attribute q :value)`

Examples:
=========

(value "#my-button") ;=> "submit" 
sourceraw docstring

visible?clj

(visible? q)
(visible? driver q)

Return true if the first element found with query q is visible on the current page in the browser.

Examples:

(visible? "div#container") ;=> true (visible? "a.hidden") ;=> false

Return true if the first element found with query `q` is visible on the current page in the browser.

Examples:
=========

(visible? "div#container") ;=> true
(visible? "a.hidden")      ;=> false
sourceraw docstring

wait-untilclj

(wait-until pred)
(wait-until pred timeout)
(wait-until pred timeout interval)
(wait-until driver pred timeout interval)

Make the browser wait until the predicate pred returns true, providing an optional timeout in milliseconds and an optional interval in milliseconds on which to attempt the predicate. If the timeout is exceeded, an exception is thrown.

The predicate is a function that accepts the browser Driver record as its single parameter, and should return a truthy/falsey value.

Examples:

;; ;; Simple example (taken from unit tests) ;; ;; Wait until the title of the page is 'asdf' ;; (execute-script "setTimeout(function () { window.document.title = 'asdf'}, 3000)") (wait-until #(= (title) "asdf"))

;; ;; Wait until an element exists ;; (... code to load page ...) (wait-until #(exists? "#foo")) (click "#foo a.bar")

Make the browser wait until the predicate `pred` returns true, providing an optional `timeout` in milliseconds and an optional `interval` in milliseconds on which to attempt the predicate. If the timeout is exceeded, an exception is thrown.

The predicate is a function that accepts the browser `Driver` record as its single parameter, and should return a truthy/falsey value.

Examples:
=========

;;
;; Simple example (taken from unit tests)
;;
;; Wait until the title of the page is 'asdf'
;;
(execute-script "setTimeout(function () { window.document.title = 'asdf'}, 3000)")
(wait-until #(= (title) "asdf"))

;;
;; Wait until an element exists
;;
(... code to load page ...)
(wait-until #(exists? "#foo"))
(click "#foo a.bar")
sourceraw docstring

windowclj

(window)
(window driver)

Return a Window that contains information about the active window and can be used for switching or resizing.

Examples:

(window)

Return a `Window` that contains information about the active window and can be used for switching or resizing.

Examples:
=========

(window)
sourceraw docstring

window-maximizeclj

(window-maximize)
(window-maximize driver)

Maximize the browser window.

Examples:

(window-maximize)

Maximize the browser window.

Examples:
=========

(window-maximize)
sourceraw docstring

window-positionclj

(window-position)
(window-position driver)

Get the position of the top-left corner of the browser's window relative to the top-left corner of your primary display, returned as a map of :x and :y integers.

Examples:

(window-position)

Get the position of the top-left corner of the browser's window relative to the top-left corner of your primary display, returned as a map of `:x` and `:y` integers.

Examples:
=========

(window-position)
sourceraw docstring

window-repositionclj

(window-reposition coordinates-map)
(window-reposition driver {:keys [x y] :as coordinates-map})

Move the top-left corner of the browser :x pixels to the right and :y pixels down from the top-left of your primary display. If you do not provide a coordinate, it's current value for the browser position will not be changed.

Examples:

(window-reposition {:x 25, :y 50}) (window-reposition {:y 50})

Move the top-left corner of the browser `:x` pixels to the right and `:y` pixels down from the top-left of your primary display. If you do not provide a coordinate, it's current value for the browser position will not be changed.

Examples:
=========

(window-reposition {:x 25, :y 50})
(window-reposition {:y 50})
sourceraw docstring

window-resizeclj

(window-resize dimensions-map)
(window-resize driver {:keys [width height] :as dimensions-map})

Resize the browser window to the given :width and :height. If a dimension is not specified, it's current value for the browser size will not be changed.

Examples:

(window-resize {:width 300 :height 400}) (window-resize {:height 400})

Resize the browser window to the given `:width` and `:height`. If a dimension is not specified, it's current value for the browser size will not be changed.

Examples:
=========

(window-resize {:width 300 :height 400})
(window-resize {:height 400})
sourceraw docstring

window-sizeclj

(window-size)
(window-size driver)

Get the size of the browser's window in pixels, returned as a map of :width and :height.

Examples:

(window-size)

Get the size of the browser's window in pixels, returned as a map of `:width` and `:height`.

Examples:
=========

(window-size)
sourceraw docstring

windowsclj

(windows)
(windows driver)

Return Window records as a seq for all open windows.

Examples:

(windows)

Return `Window` records as a seq for all open windows.

Examples:
=========

(windows)
sourceraw docstring

with-drivercljmacro

(with-driver browser-spec & body)

Given a browser-spec to start a browser, execute the forms in body, then call quit on the browser. Uses the default finder function.

Examples:

;; ;; Log into Github ;; (with-driver {:browser :firefox} (to "https://github.com") (click "a[href*='login']")

(input-text "#login_field" "your_username") (-> "#password" (input-text "your_password") submit))

Given a `browser-spec` to start a browser, execute the forms in `body`, then call `quit` on the browser. Uses the default finder function.

Examples:
=========

;;
;; Log into Github
;;
(with-driver {:browser :firefox}
  (to "https://github.com")
  (click "a[href*='login']")

  (input-text "#login_field" "your_username")
  (-> "#password"
    (input-text "your_password")
    submit))
sourceraw docstring

with-driver-fncljmacro

(with-driver-fn browser-spec finder-fn & body)

Given a browser-spec to start a browser and a finder-fn to use as a finding function, execute the forms in body, then call quit on the browser.

Examples:

;; ;; Log into Github ;; (with-driver {:browser :firefox} xpath-finder (to "https://github.com") (click "//a[text()='Login']")

(input-text "//input[@id='login_field']" "your_username") (-> "//input[@id='password']" (input-text "your_password") submit))

Given a `browser-spec` to start a browser and a `finder-fn` to use as a finding function, execute the forms in `body`, then call `quit` on the browser.

Examples:
=========

;;
;; Log into Github
;;
(with-driver {:browser :firefox} xpath-finder
  (to "https://github.com")
  (click "//a[text()='Login']")

  (input-text "//input[@id='login_field']" "your_username")
  (-> "//input[@id='password']"
    (input-text "your_password")
    submit))
sourceraw docstring

xpathclj

(xpath q)
(xpath driver q)

Return an absolute XPath path for the first element found with query q. NOTE: This function relies on executing JavaScript in the browser, and is therefore not as dependable as other functions.

Examples:

(xpath "#login_field") ;=> "/html/body/div[2]/div/div/form/div[2]/label/input"

Return an absolute XPath path for the first element found with query `q`. NOTE: This function relies on executing JavaScript in the browser, and is therefore not as dependable as other functions.

Examples:
=========

(xpath "#login_field") ;=> "/html/body/div[2]/div/div/form/div[2]/label/input"
sourceraw docstring

xpath-finderclj

(xpath-finder q)
(xpath-finder driver q)

Given a XPath query q, return a lazy seq of the elements found by calling find-elements with by-xpath. If q is an Element, it is returned unchanged.

This function is used internally by the Taxi API as *finder*. See the documentation for set-finder! for examples of extending this function or creating your own custom finder function.

Given a XPath query `q`, return a lazy seq of the elements found by calling `find-elements` with `by-xpath`. If `q` is an `Element`, it is returned unchanged.

This function is used internally by the Taxi API as `*finder*`. See the documentation for `set-finder!` for examples of extending this function or creating your own custom finder function.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close