w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
336 stars 35 forks source link

Make innerText locator work with non-element nodes #705

Closed OrKoN closed 1 month ago

OrKoN commented 2 months ago

This PR changes the innerText locator to handle non-Element nodes correctly.


Preview | Diff

sadym-chromium commented 1 month ago

@OrKoN do we have any blockers for this PR?

OrKoN commented 1 month ago

@sadym-chromium Mozilla's review I believe

sadym-chromium commented 1 month ago

There is still an open question how to deal with request with document as a start node, and maxDepth equals zero:

{
    "type": "innerText",
    "maxDepth": 0,
    "value": "BAR"
}

As long as document does not have innerText, we can:

  1. Traverse to the nearest child html element(s) and perform search there
  2. Return an empty array.
  3. Do not decrease maxDepth on non-html elements.

@OrKoN @jgraham

OrKoN commented 1 month ago

@sadym-chromium I think #2 would be something I would expect. I.e., the document does match and the max depth is 0, therefore, no recursive calls.

sadym-chromium commented 1 month ago

@sadym-chromium I think #2 would be something I would expect. I.e., the document does match and the max depth is 0, therefore, no recursive calls.

Currently spec says in this case the search should go to all the depth.

sadym-chromium commented 1 month ago

Option 2: https://github.com/web-platform-tests/wpt/pull/46346 Option 3: https://github.com/web-platform-tests/wpt/pull/46345

jgraham commented 1 month ago

I feel like users are probably going to expect not decreasing depth on document elements i.e. passing in document is equivalent to document.documentElement, but we should at least be consistent between different selector types. That would also be inconsistent with the way that node serialization works, but maybe that is less important?

whimboo commented 1 month ago

@OrKoN are you going to create / update wpt tests for this change?

sadym-chromium commented 1 month ago

I feel like users are probably going to expect not decreasing depth on document elements i.e. passing in document is equivalent to document.documentElement, but we should at least be consistent between different selector types. That would also be inconsistent with the way that node serialization works, but maybe that is less important?

Here is the spec change for this option: https://github.com/w3c/webdriver-bidi/pull/713

OrKoN commented 1 month ago

@whimboo @sadym-chromium will update it after the remaining issue is resolved

sadym-chromium commented 1 month ago