clj-commons / etaoin

Pure Clojure Webdriver protocol implementation
https://cljdoc.org/d/etaoin
Eclipse Public License 1.0
908 stars 95 forks source link

Support sequentials in addition to vectors for `query` #671

Open dgr opened 1 week ago

dgr commented 1 week ago

Problem/Opportunity Today, Etaoin supports a vector as the q argument to query. This cases query to perform a sequence of queries, making a not-necessarily fully contiguous path through the DOM. However, Etaoin doesn't support other sequential data types such as seqs or lists. There's really no reason for this as Etaoin doesn't use those types for other query behavior and in fact converts the vector to a seq internally immediately after testing for vector?. Further, many Clojure collection processing functions (e.g., filter, map, etc.) return seqs, not vectors, and so if generating the query programmatically, today the programmer has to convert to a vector before passing the query to query.

Proposed Solution Expand Etaoin's query types to allow for anything sequential?, giving the same behavior as for vectors today.

Additional context

  1. This would not be a breaking change since it liberalizes what Etaoin accepts. Today, if provided with a non-vector sequential, query throws an exception.
  2. I previously wrote the query-from-shadow-root-el function to accept anything that passes sequential?, so if we want to limit query to vectors only (today's behavior), I should probably change query-from-shadow-root-el to match.

Action Either way, I can supply a PR to update accordingly.

lread commented 1 week ago

Dave, maybe if we were starting fresh with Etaoin as a new project, this might be interesting.

But today, I don't really see the point.

Do you see a real problem this is solving for users of Etaoin?

dgr commented 1 week ago

Most of the Clojure collections functions produce seqs. This change would decreases the friction since you wouldn't have to convert to vectors all the time. I think it's low risk and non-breaking.

lread commented 1 week ago

But what pain are you solving for Etaoin users? I've not felt it. Have you explicitly felt it?

dgr commented 1 week ago

No, I have not felt it myself.

lread commented 1 week ago

So why are we solving a problem no one is having? (any lurkers, please chime in if this would solve a real problem for you).