Skip to content

Instantly share code, notes, and snippets.

@borkdude
Created August 1, 2022 21:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/627be1593c0abe20d5c53caf6aa34d85 to your computer and use it in GitHub Desktop.
Save borkdude/627be1593c0abe20d5c53caf6aa34d85 to your computer and use it in GitHub Desktop.
Playwright browser + bb chrome devtools
;; run npx playwright install to install a browser
(require '[babashka.deps :as deps])
(deps/add-deps
'{:deps {tatut/devtools {:git/url "https://github.com/tatut/clj-chrome-devtools"
:git/sha "cc96255433ca406aaba8bcee17d0d0b3b16dc423"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}})
(ns pw
(:require
[babashka.process :refer [process destroy]]
[clj-chrome-devtools.automation :as auto]
[clj-chrome-devtools.core :as core]))
(defn chrome []
(process "/Users/borkdude/Library/Caches/ms-playwright/chromium-930007/chrome-mac/Chromium.app/Contents/MacOS/Chromium --remote-debugging-port=9222"))
(def proc (chrome))
(let [browser (auto/create-automation (core/connect))]
(reset! auto/current-automation browser)
(try
(auto/to "https://babashka.org")
(prn (auto/text-of "a.my-auto"))
(finally
(destroy proc))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment