Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add examples of query functions #273

Merged
merged 3 commits into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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