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

Commit

Permalink
Replace low-level class comparisons with more generic keyword? vector…
Browse files Browse the repository at this point in the history
…? and map? fns
  • Loading branch information
semperos committed Mar 14, 2011
1 parent e8d00b8 commit 4d192f2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/clj_webdriver/core.clj
Expand Up @@ -480,14 +480,14 @@
"Given a WebDriver `driver`, optional HTML tag `tag`, and an HTML attribute-value pair `attr-val`, return the first WebElement that matches. The values of `attr-val` items must match the target exactly, unless a regex is used for a value."
([driver attr-val]
(cond
(= clojure.lang.Keyword (class attr-val))
(keyword? attr-val)
(find-element driver (by-tag-name (name attr-val))) ; supplied just :tag
(= clojure.lang.PersistentVector (class attr-val))
(vector? attr-val)
(if (query-with-ancestry-has-regex? attr-val)
(throw (IllegalArgumentException.
(str "Finding an element via ancestry does not currently support the use of regular expressions.")))
(find-element driver (by-xpath (build-xpath-with-ancestry attr-val)))) ; supplied vector of queries in hierarchy
(= clojure.lang.PersistentArrayMap (class attr-val))
(map? attr-val)
(find-it driver :* attr-val))) ; no :tag specified, use global *
([driver tag attr-val]
(if (and
Expand All @@ -512,14 +512,14 @@
"Plural version of `find-it` function; returns a vector of multiple matches."
([driver attr-val]
(cond
(= clojure.lang.Keyword (class attr-val))
(keyword? attr-val)
(find-elements driver (by-tag-name (name attr-val))) ; supplied just :tag
(= clojure.lang.PersistentVector (class attr-val))
(vector? attr-val)
(if (query-with-ancestry-has-regex? attr-val)
(throw (IllegalArgumentException.
(str "Finding an element via ancestry does not currently support the use of regular expressions.")))
(find-elements driver (by-xpath (build-xpath-with-ancestry attr-val)))) ; supplied vector of queries in hierarchy
(= clojure.lang.PersistentArrayMap (class attr-val))
(map? attr-val)
(find-them driver :* attr-val))) ; no :tag specified, use global *
([driver tag attr-val]
(if (and
Expand Down

0 comments on commit 4d192f2

Please sign in to comment.