Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove intersect, use intersects, leave intersect as exercise for reader

  • Loading branch information...
commit 6df4f6740a05f4d40e72eb922aeaedc08f1963a5 1 parent 64be2e8
@semperos authored
View
8 src/clj_webdriver/core.clj
@@ -100,7 +100,7 @@
(flash [element] "Flash the element in question, to verify you're looking at the correct element")
(focus [element] "Apply focus to the given element")
(html [element] "Retrieve the outer HTML of an element")
- (intersects*? [element-a element-b] "Return true if `element-a` intersects with `element-b`. This mirrors the Selenium-WebDriver API method, but see the `intersect?` function to compare an element against multiple other elements for intersection.")
+ (intersects? [element-a element-b] "Return true if `element-a` intersects with `element-b`. This mirrors the Selenium-WebDriver API method, but see the `intersect?` function to compare an element against multiple other elements for intersection.")
(location [element] "Given an element object, return its location as a map of its x/y coordinates")
(location-once-visible [element] "Given an element object, return its location on the screen once it is scrolled into view as a map of its x/y coordinates. The window will scroll as much as possible until the element hits the top of the page; thus even visible elements will be scrolled until they reach that point.")
(present? [element] "Returns true if the element exists and is visible")
@@ -274,12 +274,6 @@
;; Implementations of the above IElement and IFormElement protocols
(load "core_element")
-;; Higher-level functions on top of the IElement protocol
-(defn intersect?
- "Return truthy based on whether or not the first element intersects with any of the subsequent elements."
- [element & elements]
- (some true? (map #(intersects*? element %) elements)))
-
;; Key codes for non-representable keys
(defn key-code
"Representations of pressable keys that aren't text. These are stored in the Unicode PUA (Private Use Area) code points, 0xE000-0xF8FF. Refer to http://www.google.com.au/search?&q=unicode+pua&btnG=Search"
View
4 src/clj_webdriver/core_element.clj
@@ -95,7 +95,7 @@
h (.height size-obj)]
{:width w, :height h}))
- (intersects*? [element-a element-b]
+ (intersects? [element-a element-b]
(let [rect-a (rectangle element-a)
rect-b (rectangle element-b)]
(.intersects rect-a rect-b)))
@@ -288,7 +288,7 @@
(rectangle [m] (rectangle (map->Element m)))
- (intersects*? [m-a m-b] (intersects*? (map->Element m-a) (map->Element m-b)))
+ (intersects? [m-a m-b] (intersects? (map->Element m-a) (map->Element m-b)))
(tag [m] (tag (map->Element m)))
View
17 src/clj_webdriver/taxi.clj
@@ -1059,18 +1059,7 @@
([driver q]
(core/size (element driver q))))
-(defn rectangle
- "Return a `java.awt.Rectangle` with the position and dimensions of the first element found with query `q` (using the `location` and `size` functions).
-
- Examples:
- =========
-
- (rectangle \"div#login\") ;=> #<Rectangle java.awt.Rectangle[x=279,y=132,width=403,height=265]>"
- ([q] (rectangle *driver* q))
- ([driver q]
- (core/rectangle (element driver q))))
-
-(defn intersect?
+(defn intersects?
"Return true if the first element found with query `qa` intersects with the first element found with query `qb`.
Examples:
@@ -1078,9 +1067,9 @@
(intersect? \"#login\" \"#login_field\") ;=> true
(intersect? \"#login_field\" \"#password\") ;=> false"
- ([qa qb] (intersect? *driver* qa qb))
+ ([qa qb] (intersects? *driver* qa qb))
([driver qa qb]
- (core/intersects*? (element driver qa) (element driver qb))))
+ (core/intersects? (element driver qa) (element driver qb))))
(defn tag
"Return the HTML tag for the first element found with query `q`.
View
8 test/clj_webdriver/test/common.clj
@@ -202,11 +202,11 @@
(defn should-be-able-to-determine-if-elements-intersect-each-other
[driver]
(click (find-element driver {:tag :a, :text "example form"}))
- (is (intersect? (find-element driver {:id "first_name"})
- (find-element driver {:id "personal-info-wrapper"})))
+ (is (intersects? (find-element driver {:id "first_name"})
+ (find-element driver {:id "personal-info-wrapper"})))
(is (not
- (intersect? (find-element driver {:id "first_name"})
- (find-element driver {:id "last_name"})))))
+ (intersects? (find-element driver {:id "first_name"})
+ (find-element driver {:id "last_name"})))))
;; Default wrap for strings is double quotes
(defn generated-xpath-should-wrap-strings-in-double-quotes
View
4 test/clj_webdriver/test/taxi.clj
@@ -145,8 +145,8 @@
(deftest test-element-intersection
(click (find-element {:tag :a, :text "example form"}))
- (is (intersect? "#first_name" "#personal-info-wrapper"))
- (is (not (intersect? "#first_name" "#last_name"))))
+ (is (intersects? "#first_name" "#personal-info-wrapper"))
+ (is (not (intersects? "#first_name" "#last_name"))))
(deftest test-xpath-output
(is (= (xpath "a.external") "/html/body/div[2]/div/p/a")))
Please sign in to comment.
Something went wrong with that request. Please try again.