Public Vars

Back

query (clj)

(source)

function

(query driver q) (query driver q & more)
Use `driver` to find and return the first element on current page matching `q`. Query `q` can be: - `:active` the current active element. Note that this is deprecated. Use [[get-active-element]] instead to find the currently active element. - a keyword to find element by it's ID attribute: - `:my-id` - (use `{:id "my-id"}` for ids that cannot be represented as keywords) - Note that `:active` conflicts with this usage and therefore you cannot search for a keyword named `:active` and expect to find an element with ID equal to "active". In this case, use `{:id "active"}`. - a string that contains either an XPath or CSS expression, depending on the driver's locator setting. Defaults to XPath. See [[use-css]], [[with-css]], [[use-xpath]], [[with-xpath]] for methods changing the driver's locator setting. - XPath: `".//input[@id='uname'][@name='username']"` - CSS: `"input#uname[name='username']"` - a map with either `:xpath` or `:css`: - `{:xpath ".//input[@id='uname']"`}` - `{:css "input#uname[name='username']"}` - any other map is converted to an XPath expression: - `{:tag :div}` - is equivalent to XPath: `".//div"` - multiple of the above (wrapped in a vector or not). The result of each search anchors the search for the next, effectively providing a path through the DOM (though you do not have to specify each and every point in the path). - `{:tag :div} ".//input[@id='uname']"` - `[{:tag :div} ".//input[@id='uname']"]` Returns the final element's unique identifier, or throws if any element is not found. See [Selecting Elements](/doc/01-user-guide.adoc#querying) for more details. Makes use of: - https://www.w3.org/TR/webdriver2/#dfn-get-active-element - https://www.w3.org/TR/webdriver2/#dfn-find-element - https://www.w3.org/TR/webdriver2/#dfn-find-element-from-element

Examples