From f06a1ead15e24bafbded3df02123ff1800aff78d Mon Sep 17 00:00:00 2001 From: "Alex.Shi" Date: Mon, 10 Aug 2020 15:54:45 +0300 Subject: [PATCH] add examples of query functions (#273) * add examples of query functions * fix * update --- README.md | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 672a171b..21c5a70d 100644 --- a/README.md +++ b/README.md @@ -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-` macros as follows: @@ -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 @@ -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