Skip to content

query doesn't correctly handle vectors inside of vectors #672

Open
@dgr

Description

Version
1.1.42

Platform
All

Symptom
The query function accepts a number of query types (e.g., keyword, string, map) that indirectly specify a WebDriver query. query also allows for a vector argument which can contain multiple of these other query types, allowing the programmer to specify a rough path through the DOM to the desired element.

Etaoin's documentation (both doc strings and User Guide) does not speak to whether a vector can contain other vectors and if allowed what that behavior should be.

Actual behavior
Today, the behavior is a bit random. Here is some data from the REPL:

etaoin.api> (query driver {:class :foo})
"node-6D0603A0-0A6B-4BE4-AE6F-3BCA02ADEBF8"    ;; good
etaoin.api> (query driver [{:class :foo}])
"node-6D0603A0-0A6B-4BE4-AE6F-3BCA02ADEBF8"    ;; wrapping a single item in a vector is just the same as the item
etaoin.api> (query driver [[{:class :foo}]])
"node-6D0603A0-0A6B-4BE4-AE6F-3BCA02ADEBF8"    ;; putting a single vector in a vector also works !?!?
etaoin.api> (query driver [{:class :foo} {:class :target}])
"node-70F1272F-6EC3-4D32-AF00-84E60EB67927"    ;; good. just searching for a vector of things.
etaoin.api> (query driver [[{:class :foo}] [{:class :target}]])
Execution error at etaoin.impl.util/error (util.clj:38).  ;; but doing two sub-vectors blows up with an exception
Wrong query: [{:class :target}]                           ;; but oddly it blows up on the SECOND sub-vector

Expected behavior
The behavior should be consistent. I believe there are two possible choices:

  1. Vectors inside of vectors are disallowed. This should throw an exception.
  2. Vectors inside of vectors are allowed and the behavior is as if the top-level vector was flatten-ed. That is, the sub-vectors just specify sub-paths through the DOM.

Diagnosis
The code in query just needs to be updated.

Action
I can supply a PR for either choice.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions