semperos/clj-webdriver — Issue #10: Proposed new function
Author: kokaku
Created: 2011-10-29 23:46:49+00:00
State: open

I've found a need for a function that acts only if the given element already exists - seems to be a common pattern in my testing code at least. I didn't want to send in a whole find-it-form because that undoes some of the benefit of saving some typing.

```clojure
(defn wait-and-do
"Utility method for doing something after waiting for its existence"
[driver find-it-map action & args]
(apply action (wait-until driver #(exists? (find-it % find-it-map))) args))

;; example
(wait-and-do driver {:css "#edit-name"} send-keys user)
```
I'm fairly new to clojure so this is probably neither idomatic nor ideal as a final form, but I do think others might find it a useful utility function combining a very common Selenium use-case.