diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 81e9805..afc6acc 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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]) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index ff7799d..a37c1c2 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -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?]] @@ -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`. diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 2f37595..568e86c 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -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 "ĩṋṗṵţ"