Fork me on GitHub
#etaoin
<
2022-08-03
>
geraldodev23:08:54

(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 wife

lread23:08:19

Hi @U0516053R, 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?

lread00:08:47

Oh wait, is this show and tell? Lemme know!

geraldodev14:08:59

I 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.

lread14:08:37

Awesome @U0516053R! Thanks so much for sharing your success!