Skip to content
Browse files

allow fill-form to also take a list, so that the items are filled in …

…in-order.
  • Loading branch information...
1 parent 462d8b8 commit 44e6caefca873b36b61330c9cf0e8cd7229755a3 @weissjeffm weissjeffm committed May 17, 2012
Showing with 13 additions and 10 deletions.
  1. +1 −1 project.clj
  2. +12 −9 src/com/redhat/qe/auto/selenium/selenium.clj
View
2 project.clj
@@ -1,4 +1,4 @@
-(defproject com.redhat.qe/extended-selenium "1.0.3"
+(defproject com.redhat.qe/extended-selenium "1.0.3.1"
:description "An extension of the selenium RC client with extra logging and convenience methods"
:java-source-path "src"
:dependencies [[org.seleniumhq.selenium.client-drivers/selenium-java-client-driver "1.0.2"]
View
21 src/com/redhat/qe/auto/selenium/selenium.clj
@@ -57,16 +57,19 @@ will be looked up and converted to String locators (see locator-args)"
:else (browser setText el val))))
(defn fill-form
- "Fills in a standard HTML form. items-map is a mapping of locators
- of form elements, to the string values that should be selected or
- entered. 'submit' is a locator for the submit button to click at
- the end. Optional no-arg fn argument post-fn will be called after the
- submit click."
- [items-map submit & [post-fn]]
- (let [filtered (select-keys items-map
- (for [[k v] items-map :when (not (nil? v))] k))]
+ "Fills in a standard HTML form. items is a mapping of locators of
+ form elements, to the string values that should be selected or
+ entered. If you care about the order the items are filled in, use a
+ list instead of a map. 'submit' is a locator for the submit button
+ to click at the end. Optional no-arg fn argument post-fn will be
+ called after the submit click."
+ [items submit & [post-fn]]
+ (let [ordered-items (if (sequential? items)
+ (partition 2 items)
+ (into [] items))
+ filtered (filter #(not= nil (second %)) ordered-items )]
(when (-> filtered count (> 0))
- (doseq [[el val] filtered]
+ (doseq [[el val] ordered-items]
(fill-item el val))
(browser click submit)
((or post-fn load-wait)))

0 comments on commit 44e6cae

Please sign in to comment.
Something went wrong with that request. Please try again.