Hello!
I've been playing around with clj-webdriver the last few days and it's really great - thank you to all involved.
I'm stuck with one thing at the moment though, and I suspect it may be due to my lack of Clojure skills more than a clj-webdriver issue, but I was hoping someone may be kind enough to give me a push in the right direction.
Basically what I've tried to do is write some helper functions to populate fields in a form. The first one is like this:
(defn input-text-in-named-field
"Puts the text into the field whose name attribute equals n"
[n t]
(input-text (find-element {:css (str "input[name='" n "']")}) t))
In my tests this works great if I call it repeatedly, eg:
(input-text-in-named-field "user[email]" "
am2...@example.com")
(input-text-in-named-field "user[login]" "am2605")
So then I thought to myself, I could make this easier by passing in a list of name / value pairs. The next function I came up with was:
(defn input-text-in-named-fields
"Takes a list of name value pairs, and puts the value into the field with the name"
[p]
(map #(input-text-in-named-field (first %) (second %)) p))
Now here's the issue.
If I call this from inside a test, like so:
(deftest register-other
(browser-up)
(to (get-registration-url))
(input-text-in-named-fields '(["user[email]" "
am2...@example.com"], ["user[login]" "am2605"])))
The fields in the form don't get populated.
But, if I execute (input-text-in-named-fields '(["user[email]" "
am2...@example.com"], ["user[login]" "am2605"])) in the repl, it all works perfectly well. So I'm a bit confused as to what is going on.
*Note*: I've since found the quick-fill function which probably makes this unnecessary anyway, however I'd still really like to know what's going on here, as it might help me as I continue to learn Clojure...
Many thanks,
Andrew.