Created
December 19, 2020 08:11
-
-
Save jaju/7a1a0bbb09eec77448b702969a074961 to your computer and use it in GitHub Desktop.
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
(ns etaoin-play.core | |
(:require [etaoin.api :refer :all] | |
[etaoin.keys :as k])) | |
(defonce drivers (atom {})) | |
(defmacro a [action _ & body] | |
`(for [[_# driver#] @drivers] | |
(future (~action driver# ~@body)))) | |
;; You can try evaluating individual expressions in steps instead of calling the function `steps` by itself. | |
(defn steps [] | |
(swap! drivers assoc :chrome (chrome #_{:capabilities {:chromeOptions {:args ["--headless"]}}})) | |
(swap! drivers assoc :firefox (firefox)) | |
(a go drivers "https://en.wikipedia.org/") | |
(a wait-visible drivers [{:id :simpleSearch} {:tag :input :name :search}]) | |
(a fill drivers {:tag :input :name :search} "Clojure programming language") | |
(a fill drivers {:tag :input :name :search} k/enter) | |
(a wait-visible drivers {:class :mw-search-results}) | |
(a click drivers [{:class :mw-search-results} {:class :mw-search-result-heading} {:tag :a}])) | |
(comment | |
(map deref (a get-url driver)) | |
(a quit driver) | |
(reset! drivers {}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment