This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-09
Channels
- # announcements (1)
- # babashka (14)
- # calva (8)
- # chlorine-clover (3)
- # clerk (6)
- # clj-kondo (27)
- # cljdoc (20)
- # clojars (6)
- # clojure (53)
- # clojure-denver (8)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (270)
- # clojure-uk (5)
- # clojurescript (35)
- # community-development (7)
- # cursive (12)
- # datalevin (3)
- # datomic (26)
- # etaoin (23)
- # exercism (1)
- # hyperfiddle (3)
- # java (14)
- # nrepl (2)
- # off-topic (12)
- # pathom (3)
- # portal (44)
- # practicalli (2)
- # reagent (7)
- # releases (1)
- # shadow-cljs (13)
- # timbre (3)
- # xtdb (4)
I'm using Chrome. I've specificied a download location (a folder in the project dir ./dls/
) but when going to (e/go @d goog-logo-img-url)
, for instance, it just opens it in the tab
My understanding from the docs is that chrome doesn't care about what's in the :prefs
key wrt downloads, though I have tried various things there that I've seen related to Firefox prefs in the docs
Hiya @john! Yes, Etaoin will tell the webdriver to open goog-logo-img-url
in the browser. The browser should behave the same way as if you had pasted that same URL into the address bar of your browser and hit return. Two ideas for you:
1. if the image requires no authentication, do a simple HTTP get on it (outside of etaoin)
2. or maybe https://cljdoc.org/d/etaoin/etaoin/1.0.40/doc/user-guide#_capturing_screenshots might work for your use case?
Would either of those work for you?
Yeah, neither of those work trivially. But both can be massaged. I might just be missing cookies in the curl call. I'll look into it. I'm starting to understand etaoin's data model now, it's like a cljs repl, so get-
s are being serialized back to the JVM
And I can get the context menu to pop up, but I just can't click the menu items in the context menu! lol so close
Oh ya, you just want to right click and save image as... or something. Robot do my bidding, dammit! I've not tried it for non-html, but I wonder what https://cljdoc.org/d/etaoin/etaoin/1.0.40/api/etaoin.api?q=source#get-source would do for an image.
Ya @john I tried this on Chrome and Firefox and they both returned HTML for me. Probably the HTML the browser is using to display the image.
This works:
(defn save [driver get-url save-str]
(let [save-js (str "function saveAs() {
const a = document.createElement(\"a\");
fetch(\"" get-url "\")
.then(function(response) {
return response.blob();
})
.then(function(blob) {
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = \"" save-str "\";
a.click();
window.URL.revokeObjectURL(url);
});};
saveAs();")]
(e/js-execute driver save-js)))
Feel free to add that to some utility fn somewhere if you like it or can improve on it and find it useful
@john were you spawning out? There are lotsa wee Clojure HTTP clients, for example: https://github.com/babashka/http-client