semperos/clj-webdriver — Issue #18: Simplify find-it
Author: semperos
Created: 2011-11-18 17:24:33+00:00
State: open

Per discussions in the Google group, I plan to trim down the ways that `find-it` can build queries, to eliminate duplicate functionality and consolidate the syntax required to find elements on the page.

To that end, I plan to support the following syntax for `find-it` queries:

```clj
(find-it driver {:tag-name :a})
(find-it driver {:tag-name :a, :class "foo"})
(find-it driver {:xpath "//a[@class='foo']"})
(find-it driver {:css "a.foo"})
(find-it driver [{:tag-name :div, :class "content"}, {:tag-name :a, :class "foo"}])
```
This means that the find-it function takes the Driver and one of:

* A query map
* A seq of query maps

The seq of query maps will be translated into appropriate XPath that ensures items at the front are parents to items that follow, and will be supported in much the same spirit that Hiccup supports constructing HTML in pure Clojure data structures.

This will introduce a breaking change from the current signature of `find-it`, which currently allows for syntax like `(find-it driver :a {:class "foo"})` as well as `(find-it driver [:div {:class "content'"}, :a {:class "foo"}])`. Originally introduced as a convenience for quick prototyping at the REPL (one less key-attribute pair), it makes both remembering and implementing the `find-it` function more cumbersome.