(require '[etaoin.api :as e]
'[clojure.java.shell :refer [sh]]
)
;; Start WebDriver for chrome
(def driver (e/chrome)) ;; a Firefox window should appear
;; navigate to wikipedia
(e/go driver "")
(e/wait-visible driver [{:id :FiltroForm}])
(e/fill driver {:id :FiltroRegional} "BH - METROPOLITANA A - 1ª SRE")
(e/click driver {:id :FiltroMunicipio})
(e/click driver {:id :FiltroMunicipio})
(e/fill driver {:id :FiltroMunicipio} "BELO HORIZONTE")
(e/click driver {:id :FiltroCarreira})
(e/fill driver {:id :FiltroCarreira} "PEB - PROFESSOR DE EDUCAÇÃO BÁSICA")
(e/click driver {:id :FiltroCarreira})
(e/click driver {:id :btnFiltro})
(loop []
(doseq [line (range 2 17)]
(let [category (str "table.tabela>tbody>tr:nth-child(" line ") td:nth-child(6)")
action (str "table.tabela>tbody>tr:nth-child(" line ") td:nth-child(8)")]
(when-let [texto (e/get-element-text driver {:css category})]
(when (= "HISTORIA" texto)
(e/click driver {:css category})
(e/click driver {:css action})
(sh "play" "/usr/share/sounds/freedesktop/stereo/complete.oga")))))
(let [next-page "div.next>a"]
(when (e/get-element-text driver {:css next-page})
(e/click driver {:css next-page})
(recur))))
Search for county jobs for wifeI enjoyed the process, babashka + etaoin. very good combination. The css selector worked very well. And it's the first time I can remember I've made a loop recur without variables, perfect for this case when you want to loop (like a ancient goto) based on the existence of next page. Thank you for this project.
Awesome @geraldodev! Thanks so much for sharing your success!
Hi @geraldodev, happy to try and help once I understand. (maybe you are still editing your question?). What are you trying to achieve? What is happening? And what were you expecting?
Oh wait, is this show and tell? Lemme know!