-
Notifications
You must be signed in to change notification settings - Fork 93
Form Helpers
While clj-webdriver provides individual functions for interacting with HTML forms, if you don't need to monitor a form step-by-step, filling it out should be quick 'n' easy.
The quick-fill
function provides this (and is currently the only function in this namespace). You pass quick-fill
a seq of maps. Each map consists of:
- A key that describes how to find an element
- A value that describes what to do with that element
For example:
(quick-fill a-driver
[{{:name "foobar"} click},
{{:name "wowza"} #(input-text % "Text to type.")}])
As you can see, the how looks like what you'd send to find-it
or use in cache rules. The what to do is just a function that accepts one argument: the element that is found. This means that for single-arity functions like click
, you can just pass the function, whereas functions of higher arity need to be "wrapped" with either an anonymous or partial function that accepts one argument (as in the case of input-text
above).
As conveniences for common use cases, the following shortcuts are built into quick-fill
:
- If a key is a string (instead of a
find-it
style query), it is assumed to be the id attribute of the element you're targeting - If a value is a string (instead of a function), it is assumed to be a string that you want to input into the target element (i.e. with the
input-text
function)
For example:
(quick-fill a-driver
[{"target-id" click},
{{:name "wowza"} "Text to type.")}])
The clj-webdriver Uncyclo by Daniel Gregoire and community is licensed under a Creative Commons Attribution 4.0 International License. Based on a work at https://github.com/semperos/clj-webdriver/wiki.