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

Extend locateNodes with a locator to get navigable's container element #811

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2967,6 +2967,7 @@ To <dfn>await a navigation</dfn> given |navigable|, |request|, |wait condition|,
browsingContext.Locator = (
browsingContext.AccessibilityLocator /
browsingContext.CssLocator /
browsingContext.ContextLocator /
browsingContext.InnerTextLocator /
browsingContext.XPathLocator
)
Expand All @@ -2984,6 +2985,13 @@ browsingContext.CssLocator = {
value: text
}

browsingContext.ContextLocator = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find it puzzling when naming it ContextLocator but then returning a Node which is the container element of a context. Why was it changed from ContainerLocator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed on request by @jgraham because the locator name reflects the criteria for search and not the return value. I.e., browsingContext.ContextLocator locates by a context selector, browsingContext.CssLocator locates by a CSS selector.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m still not entirely sold on this API, but if @jgraham is okay with it, we can move forward.

type: "context",
value: {
context: browsingContext.BrowsingContext,
}
}

browsingContext.InnerTextLocator = {
type: "innerText",
value: text,
Expand Down Expand Up @@ -3783,6 +3791,18 @@ To <dfn>locate nodes using CSS</dfn> with given |navigable|, |context nodes|,

</div>

<div algorithm="locate the container element">
To <dfn>locate the container element</dfn> given |navigable|:

1. Let |returned nodes| be an empty [=/list=].

1. If |navigable|'s [=navigable/container=] is not null,
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
append |navigable|'s [=navigable/container=] to |returned nodes|.

1. Return |returned nodes|.

</div>

<div algorithm="locate nodes using XPath">

To <dfn>locate nodes using XPath</dfn> with given |navigable|, |context nodes|,
Expand Down Expand Up @@ -4050,6 +4070,25 @@ The [=remote end steps=] with |session| and |command parameters| are:
1. Let |result nodes| be [=locate nodes using accessibility attributes=]
given |context nodes|, |selector|, and |maximum returned node count|.

<dt>|type| is the string "<code>context</code>"
<dd>

1. If |start nodes parameter| is not null,
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
return [=error=] with [=error code=] "<code>invalid argument</code>".

1. Let |selector| be |locator|["<code>value</code>"].

1. Let |context id| be |selector|["<code>context</code>"].

1. Let |child navigable| be the result of [=trying=] to [=get a navigable=] with |context id|.

1. If |child navigable|'s [=navigable/parent=] is not |navigable|,
return [=error=] with [=error code=] "<code>invalid argument</code>".

1. Let |result nodes| be [=locate the container element=] given |child navigable|.

1. Assert: For each |node| in |result nodes|, |node|'s [=/node navigable=] is |navigable|.
OrKoN marked this conversation as resolved.
Show resolved Hide resolved

1. Assert: |maximum returned node count| is null or [=list/size=] of |result nodes| is less
than or equal to |maximum returned node count|.

Expand Down