Skip to content

Commit bee5211

Browse files
dgrlread
andauthored
Implement fill-active-human (clj-commons#629) (clj-commons#635)
* Implement fill-active-human (clj-commons#629) * Update textarea field fill to use fill-active-human --------- Co-authored-by: Lee Read <[email protected]>
1 parent abdbb21 commit bee5211

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ A release with an intentional breaking changes is marked with:
2222
* Changes
2323
** {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])
2424
** {issue}559[#559]: Make `get-active-element` a public API. This was previously private. ({person}dgr[@dgr])
25+
** {issue}629[#629]: Added `fill-active-human` as a convenience function that fills the currently active input using `fill-human-el`. ({person}dgr[@dgr])
2526
** {issue}620[#620]: Get stricter when unwrapping elements. ({person}dgr[@dgr])
26-
2727
* Docs
2828
** {issue}559[#559]: Deprecate use of `:active` with `query` and other APIs that use `query` under the hood. ({person}dgr[@dgr])
2929

src/etaoin/api.clj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
5757
**Inputs/Forms**
5858
- [[fill]] [[fill-active]] [[fill-el]] [[fill-multi]]
59-
- [[fill-human]] [[fill-human-el]] [[fill-human-multi]]
59+
- [[fill-human]] [[fill-active-human]] [[fill-human-el]] [[fill-human-multi]]
6060
- [[select]] [[selected?]] [[selected-el?]]
6161
- [[upload-file]] [[remote-file]]
6262
- [[disabled?]] [[enabled?]]
@@ -2786,6 +2786,14 @@
27862786
([driver q text opts]
27872787
(fill-human-el driver (query driver q) text opts)))
27882788

2789+
(defn fill-active-human
2790+
"Fills the currently active element with `text` as if it were a real
2791+
human using `opts`. This is a simple convience function wrapped
2792+
around `get-active-element` and `fill-human-el`."
2793+
([driver text] (fill-active-human driver text {}))
2794+
([driver text opts]
2795+
(fill-human-el driver (get-active-element driver) text opts)))
2796+
27892797
(defn fill-human-multi
27902798
"Have `driver` fill multiple elements as if it were a real human being via `q-text` using `opts`.
27912799

test/etaoin/api_test.clj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,19 @@
186186
(e/when-safari (e/wait 3))
187187
(-> e/get-url
188188
(str/ends-with? "?login=1test2+A&password=&message=")
189-
is))))
189+
is)))
190+
(testing "fill active human"
191+
(doto *driver*
192+
(e/click :simple-input)
193+
(e/fill-active-human "MyLogin2")
194+
(e/click :simple-password)
195+
(e/fill-active-human "MyPassword2")
196+
(e/click :simple-textarea)
197+
(e/fill-active-human "Some text 2")
198+
(e/click :simple-submit)
199+
(e/when-safari (e/wait 3)))
200+
(is (str/ends-with? (e/get-url *driver*)
201+
"?login=MyLogin2&password=MyPassword2&message=Some+text+2"))))
190202

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

0 commit comments

Comments
 (0)