This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-11
Channels
- # aws (2)
- # beginners (38)
- # boot (21)
- # boot-dev (8)
- # cider (51)
- # cljsrn (3)
- # clojars (23)
- # clojure (99)
- # clojure-austin (7)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-dusseldorf (1)
- # clojure-estonia (20)
- # clojure-greece (4)
- # clojure-italy (3)
- # clojure-russia (1)
- # clojure-spec (28)
- # clojure-uk (47)
- # clojurescript (47)
- # core-logic (3)
- # cursive (9)
- # data-science (1)
- # datomic (50)
- # docs (12)
- # emacs (5)
- # fulcro (60)
- # graphql (33)
- # hoplon (8)
- # jobs-discuss (1)
- # keechma (31)
- # lein-figwheel (10)
- # leiningen (4)
- # off-topic (70)
- # om (1)
- # onyx (15)
- # pedestal (5)
- # re-frame (185)
- # reagent (14)
- # remote-jobs (8)
- # ring-swagger (7)
- # rum (17)
- # shadow-cljs (193)
- # specter (6)
- # sql (51)
- # unrepl (8)
Thanks @mikethompson. Just feeling frustrating using D3.js with re-frame, because of the un-immutability nature of D3.js.
Not public
BTW, @cmal I assume you have looked at: https://github.com/Day8/re-frame/blob/master/docs/Using-Stateful-JS-Components.md
(previous link corrected)
Thank you, @mikethompson. I will have a look.
@raymcdermott Weāre using headless Chrome, but headless Firefox is now also a thing
@raymcdermott running it in a Docker container, so nothing fancy to install on our CI server
This wrapper around webdriver API makes things easy for us: https://github.com/igrishaev/etaoin All from JVM -> Docker container running ChromeDriver / headless Chrome
Wow, etaoin looks very interesting, thanks for mentioning it.
so maybe Iām doing it wrong ā¦ can you drive the non-visuals (dispatch / subscribe) type tests from etaoin?
We donāt test at that level. Just āuser visits this page, does this and that, and then this should be on the screenā.
@raymcdermott E.g. like this, you could execute JS:
(eta/js-execute
*chrome*
"$(\".title-text:contains('Frequency Table')\")[0].scrollIntoView()"))
(code is now obsolete, because etaoin has a scroll function now)@raymcdermott why are you testing on this level instead of filling the form on the UI level?
sure, just curious. still need another form of testing on the UI level to ensure nothing breaks there
but maybe node or something is a better fit for this kind of testing, since you donāt even need a browser for this
re-frame is meant for browsers though and there are some things (like FormData for example) that might not work so easily on node.js
ok, you could start the test from within the app using etaoin js execution and then read the browser logs to see if the test ran ok or not.
I think my suggestion may be not a good one then, because we test on a higher level. Good luck!
(re 4:01PM, actually etaoin returns the result from the js expression as well, so if your tests are totally sync that would also work)
@borkdude some things talk to servers async ā¦ but anyway who here wants to code in JS though? OK as a hack but would prefer to keep the code in CLJS and the infra can be node JS or browser JS as needed
yeah, I meant your re-frame test. it says run-test-sync
so I thought that could work
ok, itās just showing how you can execute JS. In your case it would be (eta/js-execute ā(whatever-test)ā) and then assert from the JVM that everything is fine
FWIW, Iām using this Docker to spin up a headless chrome: https://hub.docker.com/r/robcherry/docker-chromedriver/
but during development Iām not using a headless one btw, I want to look at what itās doing
well, you can use regular clojure.test to drive etaoin. e.g. https://github.com/igrishaev/etaoin#writing-integration-tests-for-your-application but Iāve written my own glue between clojure.test and etaoin
you can do e.g. (is (= 3 (eta/js-execute "1+2")))
, but Iām not sure how far you would get with that
I am assuming this code runs inside a browser where your app is loaded, no? https://clojurians.slack.com/files/U04V5V0V4/F8RCVN0JW/re-frame-tests.clj
Iām hesitant, because itās only one dayā¦ the travel would be longer than the fun
I know what you mean ā¦. but weāre having a defn road trip ā¦ both Vijay and myself will be talking
I do it like this:
(defn contains-text? [text]
(format ā//*[contains(text(),ā%sā)]ā text))
(defn contains-class? [class]
(format ā//*[contains(@class, ā%sā)]ā class))
and then e.g.:
(eta/wait-exists *chrome* [{:tag :div :class āsearch-summary-textā}
(contains-text? āresultsā)])
note that when you use :class
it only matches on the full class, so this is a workaround for it
Thereās also https://github.com/igrishaev/etaoin/blob/master/src/etaoin/api.clj#L1662 but not sure where to use that
A query might be: - a string, so the current browserās locator will be used. Examples: //div[@id=ācontentā] for XPath, div.article for CSS selector
I gave you an example with a query.
[{:tag :div :class "search-summary-text"}
(contains-text? "results")]
means:
search for an element with class ā¦ which has a child element that contains text ā¦.has-class seems to do the same thing yeah, has-text is also there. It didnāt exist when I wrote this. Iām an early adopter š
I tried to learn Flemish by watching TV but I can only endure one form of punishment at a time
yes, that also works, but youād have to specify the full class. also visible can cause unexpected results, because in some cases the element never becomes visible. Thatās why I use wait-exists instead
working with the full class works, until you add a classā¦ e.g. āactiveā, then it quickly breaks
The nice thing about etaoin is that itās just a simple wrapper around an API, so if something is missing, just add a clj-http call somewhere
https://www.dropbox.com/s/ubzkz85943zgsjk/Screenshot%202018-01-12%2012.07.50.png?dl=0
if you have a question about the impact of post-Hegelian idealism on Clojure, now is your chance
am trying to do an oauth2 flow using auth0 and it all works fine with chrome but fails when running headless ā¦. have you seen anything like that?
+ you can execute some arbitrary js to test for elements etc. for debugging from the REPL
How do Haskell people even get by. The type system doesnāt help you in any way with issues like this.
Donāt have anything to ask Zach, except to thank him for Aleph, the fundamental thing in Yada that we are gratefully using