Skip to content

Instantly share code, notes, and snippets.

@semperos
Created July 25, 2012 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save semperos/3178729 to your computer and use it in GitHub Desktop.
Save semperos/3178729 to your computer and use it in GitHub Desktop.
Webdriver Logic example
(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