Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using * as locator returns no nodes #2539

Open
christian-bromann opened this issue Aug 28, 2024 · 6 comments
Open

Using * as locator returns no nodes #2539

christian-bromann opened this issue Aug 28, 2024 · 6 comments
Assignees

Comments

@christian-bromann
Copy link
Contributor

This behavior is observed in stable and canary (130.0.6682.2)

Expected Behavior

If I call browsingContext.locateNodes with the following parameters:

{
  "locator": {"type":"css","value":"*"},
  "context":"4ab66b36-ae31-4c38-90bb-40d97bd48b36"
}

I would expect that it would fetch the ` tag as it is the first element in the DOM tree.

Actual Behavior

Firefox: ✅ works as expected and returns

{
    "nodes": [
        {
            "type": "node",
            "sharedId": "d2030884-983d-45f9-85fd-10552d1e9f70",
            "value": {
                "nodeType": 1,
                "localName": "head",
                "namespaceURI": "http://www.w3.org/1999/xhtml",
                "childNodeCount": 0,
                "attributes": {},
                "shadowRoot": null
            }
        },
        {
            "type": "node",
            "sharedId": "9d66bb03-20fd-4e5d-bacf-68bbdda1d15d",
            "value": {
                "nodeType": 1,
                "localName": "body",
                "namespaceURI": "http://www.w3.org/1999/xhtml",
                "childNodeCount": 0,
                "attributes": {},
                "shadowRoot": null
            }
        }
    ]
}

Chrome: ❌ fails even though * is a valid selector and returns

{
    "nodes": []
}

Reproducible Example

See https://github.com/christian-bromann/bidi-locateNodes-error, clone the repo, install dependencies, and call npm run wdio

@OrKoN
Copy link
Collaborator

OrKoN commented Aug 29, 2024

@sadym-chromium PTAL

@sadym-chromium sadym-chromium self-assigned this Aug 29, 2024
@sadym-chromium
Copy link
Collaborator

e2e repro works: #2543. Looking further

@sadym-chromium
Copy link
Collaborator

UPD: the issue should be fixed by #2543

@sadym-chromium
Copy link
Collaborator

The root cause is in the fact Chromium BiDi used document.body instead of document, which excluded head form the selectors.

sadym-chromium added a commit that referenced this issue Aug 29, 2024
Addressing #2539

According to the spec, the default `startNodes` of the
`browsingContext.locateNodes` is `document`, not `document.body`.
@christian-bromann
Copy link
Contributor Author

christian-bromann commented Aug 29, 2024

Thanks for fixing this. @sadym-chromium why would it still return no nodes given the selector * then? I would assume it would return the first node in the document.body tree.

@sadym-chromium
Copy link
Collaborator

Thanks for fixing this. @sadym-chromium why would it still return no nodes given the selector * then? I would assume it would return the first node in the document.body tree.

In your example the page is "about:blank", and there are no elements in the "document.body"

alexnj pushed a commit to alexnj/chromium-bidi that referenced this issue Sep 4, 2024
…2543)

Addressing GoogleChromeLabs#2539

According to the spec, the default `startNodes` of the
`browsingContext.locateNodes` is `document`, not `document.body`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants