etaoin

borkdude 2017-10-20T10:51:26.000037Z

Is it possible to query on the contents of a tag, like <div>Hello</div> with the map notation in etaoin?

metametadata 2017-10-20T11:23:56.000246Z

@borkdude (e/get-element-text driver {:id :my-div}) ?

borkdude 2017-10-20T11:24:39.000269Z

I don’t have an id in that page. It’s more like: wait for the element with this class and this content. But I can do it with xpath

borkdude 2017-10-20T11:24:59.000010Z

something like this: (wait-exists chrome {:tag :div :class "title-text" :content "Hello"})

metametadata 2017-10-20T11:25:07.000280Z

aah, I see, I dunno then 🙂

borkdude 2017-10-20T11:25:11.000091Z

but I don’t know if :content is supported

metametadata 2017-10-20T11:25:51.000275Z

looking at my tests I also used xpath for this: (e/click driver {:xpath "//a[contains(text(), 'Sign Out')]"})

borkdude 2017-10-20T11:26:04.000168Z

ok

borkdude 2017-10-20T11:28:31.000405Z

(exists? chrome "//div[@class='title-text' and 'Hello']")

borkdude 2017-10-20T11:28:48.000090Z

contains is also a good one, more robust

borkdude 2017-10-20T11:30:42.000249Z

In addition to etaoin I started using https://github.com/xebia/VisualReview which is awesome

metametadata 2017-10-20T11:32:20.000160Z

so do you use VisualReview for CSS problems and such?

borkdude 2017-10-20T11:32:44.000298Z

it gives a visual diff of the current and previous screenshots

borkdude 2017-10-20T11:33:01.000232Z

so it only tests on the screenshot level

metametadata 2017-10-20T11:33:11.000213Z

right

borkdude 2017-10-20T11:33:32.000178Z

that’s actually what we want, we’re not going to use a lot of assertions, but just inspection via screenshots

borkdude 2017-10-20T11:33:40.000338Z

for now

metametadata 2017-10-20T11:33:49.000080Z

you may be interested in this thread maybe: https://twitter.com/searls/status/919594505938112512

igrishaev 2017-10-20T11:33:53.000223Z

@borkdude there is an issue for that to extend map notation: https://github.com/igrishaev/etaoin/issues/23

👌 1
igrishaev 2017-10-20T11:34:58.000001Z

you may share your proposals there. As I see it, for exact text equality we could use {:tag :div :fn/text "Hello!"}

borkdude 2017-10-20T11:36:36.000139Z

Why not make it more flexible:

{:tag :div :xpath "contains(text(),'Pico labeler')]"}

borkdude 2017-10-20T11:36:56.000071Z

so, select the stuff you want and apply xpath to those values?

igrishaev 2017-10-20T11:37:53.000167Z

In my project, we’ve got three common cases: 1. exact text equality 2. HTML class attribute contains a specific class 3 text contains something I think we may add special tags for that cases.

borkdude 2017-10-20T11:37:56.000043Z

I also wondered about, what does it mean when you pass a vector of maps? Those do not mean sub selections of the previous right?

igrishaev 2017-10-20T11:38:08.000085Z

hm, your example looks well

igrishaev 2017-10-20T11:38:32.000198Z

yes, a vectors means nested selection

borkdude 2017-10-20T11:38:36.000377Z

ah it does

borkdude 2017-10-20T11:38:46.000107Z

thanks

borkdude 2017-10-20T11:39:16.000231Z

so then you could write: [{:tag :div} {:xpath "contains(text(),'Pico labeler')]"}] already right?

igrishaev 2017-10-20T11:40:06.000060Z

well, probably you could. You may try it repl, there is a function that expands it into a final string expression.

borkdude 2017-10-20T11:42:27.000358Z

(exists? chrome {:xpath "//div[@class='title-text' and contains(text(),'Pico labeler')]"}) ;; true
(exists? chrome [{:tag :div :class "title-text"} {:xpath "contains(text(),'Pico labeler')"}]) ;; false

igrishaev 2017-10-20T11:43:12.000179Z

what if the second clause would be not a map with :xpath key, but just a string?

borkdude 2017-10-20T11:43:45.000240Z

still false. what’s the function to expand?

igrishaev 2017-10-20T11:43:59.000279Z

q-xpath

igrishaev 2017-10-20T11:44:07.000339Z

sorry no

borkdude 2017-10-20T11:44:33.000362Z

brb

igrishaev 2017-10-20T11:49:03.000090Z

".//div[@class='title-text'][contains(text(),'Pico labeler']" does it work for you?

igrishaev 2017-10-20T11:50:46.000338Z

this form could be expressed as {:tag :div :fn/has-class :title-text :fn/has-text "Pico labeler"}.

igrishaev 2017-10-20T11:51:17.000238Z

I mean, there are no rules for :fn/... fields, but I may add them.

borkdude 2017-10-20T12:01:10.000056Z

I’m in a meeting, I’ll be back this afternoon

borkdude 2017-10-20T16:09:09.000155Z

I’m back

borkdude 2017-10-20T16:15:54.000083Z

@igrishaev To come back to your question:

(exists? chrome {:xpath "//div[@class='title-text' and contains(text(),'Pico labeler')]"}) ;; true
(exists? chrome "//div[@class='title-text' and contains(text(),'Pico labeler']") ;; false

borkdude 2017-10-20T16:16:38.000045Z

I’ll try q-xpath

borkdude 2017-10-20T16:30:07.000543Z

This works now:

(eta/exists? chrome [{:tag :div :class "title-text"} {:xpath "//*[contains(text(),'Pico labeler')]"}])

borkdude 2017-10-20T16:30:22.000364Z

The thing was I needed to add the //*

borkdude 2017-10-20T17:43:27.000416Z

can I scroll with the etaoin lib?