Created
July 25, 2012 21:19
-
-
Save semperos/3178729 to your computer and use it in GitHub Desktop.
Webdriver Logic example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn attributeo | |
"A relation where `elem` has value `value` for its `attr` attribute" | |
[elem attr value] | |
(fn [a] | |
(to-stream | |
(->> (for [el (wd/find-elements *driver* *search-domain*) | |
attribute *html-attributes*] | |
(unify a | |
[elem attr value] | |
[el attribute (wd/attribute el attribute)])) | |
(remove not))))) | |
;; Run it | |
(run 2 [q] | |
(fresh [an-el an-attr] | |
(attributeo an-el an-attr "https://github.com/blog") | |
(== q [an-attr an-el]))) | |
;; Returns: | |
;; ([:href | |
;; {:webelement | |
;; #<Tag: <a>, Text: Blog, Href: https://github.com/blog, Object: [[FirefoxDriver: firefox on MAC (2b3afa4b-c0a7-bb45-b8be-4155f91e3cd9)] -> xpath: //*]>}] | |
;; [:href | |
;; {:webelement | |
;; #<Tag: <a>, Text: Blog, Href: https://github.com/blog, Object: [[FirefoxDriver: firefox on MAC (2b3afa4b-c0a7-bb45-b8be-4155f91e3cd9)] -> xpath: //*]>}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment