Skip to content

Commit

Permalink
add examples of query functions (#273)
Browse files Browse the repository at this point in the history
* add examples of query functions

* fix

* update
  • Loading branch information
Uunnamed authored Aug 10, 2020
1 parent a783dc6 commit f06a1ea
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,22 @@ may simplify it using `doto` macros:

In that case, your code looks like a DSL designed just for such purposes.

You can use `fill-multi` to shorten the code like:

``` clojure
(fill driver :login "login")
(fill driver :password "pass")
(fill driver :textarea "some text")
```

into

``` clojure
(fill-multi driver {:login "login"
:password "pass"
:textarea "some text"})
```

If any exception occurs during a browser session, the external process might
hang forever until you kill it manually. To prevent it, use `with-<browser>`
macros as follows:
Expand Down Expand Up @@ -332,6 +348,25 @@ rules are:

Examples:

- find the first `div` tag
```clojure
(query driver {:tag :div})
;; expands into .//div
```

- find the n-th `div` tag
```clojure
(query driver {:tag :div :index 1})
;; expands into .//div[1]
```

- find the tag `a` with the class attribute equals to `active`

``` clojure
(query driver {:tag :a :class "active"})
;; ".//a[@class=\"active\"]"
```

- find a form by its attributes:

```clojure
Expand Down Expand Up @@ -367,11 +402,13 @@ Examples:
;; .//*[contains(@class, "active")][contains(@class, "sticky")][contains(@class, "marked")]
```

- find all the disabled input widgets:
- find all the enabled/disabled input widgets:

```clojure
(query driver {:tag :input :fn/disabled true})
;; .//input[@disabled=true()]
(query driver {:tag :input :fn/enabled true})
;; .//input[@enabled=true()]
```

### Vector syntax for querying
Expand Down

0 comments on commit f06a1ea

Please sign in to comment.