etaoin

dottedmag 2018-05-13T10:30:21.000002Z

How do I list frames in etaoin? I've got an ancient page with frameset and frames. The frame I need does not have an id, only name attribute, and I can't figure out how to select it.

dottedmag 2018-05-13T10:34:07.000067Z

Hmm, after some poking around I've got it working: (switch-frame driver {:tag "frame" :name "mainFrame"})

igrishaev 2018-05-13T19:30:59.000146Z

@dottedmag the switch-frame function takes any term that is used to query DOM. A keywords stands for an element’s ID, but you are also welcome to pass a map or a vector of maps.

igrishaev 2018-05-13T19:31:41.000162Z

This page https://github.com/igrishaev/etaoin#querying-elements describes the query rules.

dottedmag 2018-05-13T19:32:34.000055Z

@igrishaev Thanks, I've already got used to it 🙂

dottedmag 2018-05-13T19:33:58.000085Z

@igrishaev By any chance, do you know what's the best way to query elements in Shadow DOM? I'm using {:css "* /deep/ input"}, but /deep/ is deprecated.

igrishaev 2018-05-13T19:35:43.000026Z

@dottedmag well, I’m not too familiar with the shadow DOM. The last time, I remember, I had to run a js script to query them.

dottedmag 2018-05-13T19:36:55.000029Z

OK

dottedmag 2018-05-13T19:38:22.000122Z

Another question: I use (query-all driver "//select[@name=\"...\"]/option") and (map #'e/get-element-value-el %) on the result in order to obtain a list of options for select element, is there a better way?

igrishaev 2018-05-13T19:41:17.000060Z

yes that works, although I consider this is being a bit long. I’ve beed thinking on some refactoring here but without any result.

igrishaev 2018-05-13T19:42:26.000085Z

I mean, query/query-all return a system id, but not an object as Selenium does.

dottedmag 2018-05-13T19:43:51.000090Z

get-element-value-el is not exported, so it looks a bit dirty.

igrishaev 2018-05-13T19:44:44.000102Z

Yes, it’s for internal use I remember. It would be great to return not a plain id but wrap it with a typed record maybe to let other functions be more flexible.

dottedmag 2018-05-13T19:44:45.000074Z

And will break for non-Chrome, as I see from the code.

dottedmag 2018-05-13T19:45:04.000067Z

Would that also remove the -el/non-`-el` distinction from API?

igrishaev 2018-05-13T19:45:32.000055Z

Hm, it should work for non-Chrome, why not?

dottedmag 2018-05-13T19:46:16.000053Z

I see that get-element-value delegates to get-element-attr and get-element-property for Safari, Phantom and FF.

igrishaev 2018-05-13T19:46:18.000043Z

-el functions take not a query term but a naked ID produced by query/query-all

igrishaev 2018-05-13T19:48:47.000074Z

ah, I see now. Yes, get-element-value-el works in Chrome only, that’s why it’s low-level and isn’t exported.

igrishaev 2018-05-13T19:49:39.000027Z

So yes, the API aren’t flexible enough, some refactoring is required.

dottedmag 2018-05-13T19:51:41.000018Z

OK, so I won't be looking for a better way for now 🙂