Skip to content

Commit

Permalink
Implement fill-active-human (#629) (#635)
Browse files Browse the repository at this point in the history
* Implement fill-active-human (#629)

* Update textarea field fill to use fill-active-human

---------

Co-authored-by: Lee Read <[email protected]>
  • Loading branch information
dgr and lread authored Aug 20, 2024
1 parent abdbb21 commit bee5211
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ A release with an intentional breaking changes is marked with:
* Changes
** {issue}559[#559]: Create `query-from` and `query-all-from` as replacements for `child` and `children`. Rewrite logic such that `q` parameter allows for vector syntax similar to `query` and `query-all`. Deprecate `child` and `children`. ({person}dgr[@dgr])
** {issue}559[#559]: Make `get-active-element` a public API. This was previously private. ({person}dgr[@dgr])
** {issue}629[#629]: Added `fill-active-human` as a convenience function that fills the currently active input using `fill-human-el`. ({person}dgr[@dgr])
** {issue}620[#620]: Get stricter when unwrapping elements. ({person}dgr[@dgr])

* Docs
** {issue}559[#559]: Deprecate use of `:active` with `query` and other APIs that use `query` under the hood. ({person}dgr[@dgr])

Expand Down
10 changes: 9 additions & 1 deletion src/etaoin/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
**Inputs/Forms**
- [[fill]] [[fill-active]] [[fill-el]] [[fill-multi]]
- [[fill-human]] [[fill-human-el]] [[fill-human-multi]]
- [[fill-human]] [[fill-active-human]] [[fill-human-el]] [[fill-human-multi]]
- [[select]] [[selected?]] [[selected-el?]]
- [[upload-file]] [[remote-file]]
- [[disabled?]] [[enabled?]]
Expand Down Expand Up @@ -2786,6 +2786,14 @@
([driver q text opts]
(fill-human-el driver (query driver q) text opts)))

(defn fill-active-human
"Fills the currently active element with `text` as if it were a real
human using `opts`. This is a simple convience function wrapped
around `get-active-element` and `fill-human-el`."
([driver text] (fill-active-human driver text {}))
([driver text opts]
(fill-human-el driver (get-active-element driver) text opts)))

(defn fill-human-multi
"Have `driver` fill multiple elements as if it were a real human being via `q-text` using `opts`.
Expand Down
14 changes: 13 additions & 1 deletion test/etaoin/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,19 @@
(e/when-safari (e/wait 3))
(-> e/get-url
(str/ends-with? "?login=1test2+A&password=&message=")
is))))
is)))
(testing "fill active human"
(doto *driver*
(e/click :simple-input)
(e/fill-active-human "MyLogin2")
(e/click :simple-password)
(e/fill-active-human "MyPassword2")
(e/click :simple-textarea)
(e/fill-active-human "Some text 2")
(e/click :simple-submit)
(e/when-safari (e/wait 3)))
(is (str/ends-with? (e/get-url *driver*)
"?login=MyLogin2&password=MyPassword2&message=Some+text+2"))))

(deftest test-unicode-bmp-input
(let [data {:simple-input "ĩṋṗṵţ"
Expand Down

0 comments on commit bee5211

Please sign in to comment.