Skip to content

Commit

Permalink
add fn select decription && some fix (#270)
Browse files Browse the repository at this point in the history
* add fn `select` decription && some fix

* update

* fix
  • Loading branch information
Uunnamed authored Aug 7, 2020
1 parent 943d4a7 commit b65d721
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ after a mysteries note was produced on it.
* [Vector syntax for querying](#vector-syntax-for-querying)
* [Advanced queries](#advanced-queries)
+ [Querying the *nth* element matched](#querying-the-nth-element-matched)
+ [Getting elements like in a tree](getting-elements-like-in-a-tree)
* [Interacting with queried elements](#interacting-with-queried-elements)
- [Emulation of human input](#emulation-of-human-input)
- [Mouse clicks](#mouse-clicks)
Expand Down Expand Up @@ -203,6 +204,17 @@ The good news you may automate your browser directly from the REPL:
(fill driver {:tag :input :name :search} k/enter)
(wait-visible driver {:class :mw-search-results})

;; select an `option` in select-box by visible text
;; <select id="country">
;; <option value="rf">Russia</option>
;; <option value="usa">United States</option>
;; <option value="uk">United Kingdom</option>
;; <option value="fr">France</option>
;;</select>
(select driver :country "France")
(get-element-value driver :country)
;;=> "fr"

;; I'm sure the first link is what I was looking for
(click driver [{:class :mw-search-results} {:class :mw-search-result-heading} {:tag :a}])
(wait-visible driver {:id :firstHeading})
Expand Down
2 changes: 1 addition & 1 deletion src/etaoin/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@
- `q`: a query term, see `query` function for more info,
- `text`: a string to input."
- `text`: a string, text in the option you want to select"
[driver q text]
(let [el (query driver q {:tag :option :fn/has-text text})]
(click-el driver el)))
Expand Down

0 comments on commit b65d721

Please sign in to comment.