From e25f510a6ce923e6655db7cf1c0bf96473970e9a Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Mon, 13 Jan 2025 09:43:49 +0100 Subject: [PATCH] Extend locateNodes with a locator to get navigable's container element (#811) * Add a way to find navigable's container * Fix build by referencing css22 instead of css2 (#816) * address review comments * Update index.bs Co-authored-by: Maksim Sadym <69349599+sadym-chromium@users.noreply.github.com> --------- Co-authored-by: Maksim Sadym <69349599+sadym-chromium@users.noreply.github.com> --- index.bs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/index.bs b/index.bs index daf11c3c..4157ba0b 100644 --- a/index.bs +++ b/index.bs @@ -3075,6 +3075,7 @@ To await a navigation given |navigable|, |request|, |wait condition|, browsingContext.Locator = ( browsingContext.AccessibilityLocator / browsingContext.CssLocator / + browsingContext.ContextLocator / browsingContext.InnerTextLocator / browsingContext.XPathLocator ) @@ -3092,6 +3093,13 @@ browsingContext.CssLocator = { value: text } +browsingContext.ContextLocator = { + type: "context", + value: { + context: browsingContext.BrowsingContext, + } +} + browsingContext.InnerTextLocator = { type: "innerText", value: text, @@ -3891,6 +3899,18 @@ To locate nodes using CSS with given |navigable|, |context nodes|, +
+To locate the container element given |navigable|: + +1. Let |returned nodes| be an empty [=/list=]. + +1. If |navigable|'s [=navigable/container=] is not null, + append |navigable|'s [=navigable/container=] to |returned nodes|. + +1. Return |returned nodes|. + +
+
To locate nodes using XPath with given |navigable|, |context nodes|, @@ -4158,6 +4178,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|. +
|type| is the string "context" +
+ + 1. If |start nodes parameter| is not null, + return [=error=] with [=error code=] "invalid argument". + + 1. Let |selector| be |locator|["value"]. + + 1. Let |context id| be |selector|["context"]. + + 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=] "invalid argument". + + 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|. + 1. Assert: |maximum returned node count| is null or [=list/size=] of |result nodes| is less than or equal to |maximum returned node count|.