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

Implement fill-active-human (#629) #635

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
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
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
Loading