Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Form Helpers

semperos edited this page Nov 8, 2011 · 9 revisions

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.

Quick Fill

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).

Shortcuts

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.")}])
Clone this wiki locally