1+ using System ;
12using System . Threading ;
23using CSF . Screenplay . Selenium . Builders ;
34using CSF . Screenplay . Selenium . Elements ;
45using CSF . Screenplay . Selenium . Queries ;
6+ using CSF . Screenplay . Selenium . Questions ;
7+ using CSF . Screenplay . Selenium . Tasks ;
58
69namespace CSF . Screenplay . Selenium
710{
@@ -106,5 +109,93 @@ public static FilterElementsBuilder Filter(SeleniumElementCollection elements)
106109 /// <param name="element">The elements to interrogate for values.</param>
107110 /// <returns>A builder which chooses the query</returns>
108111 public static QuestionMultiQueryBuilder ReadFromTheCollectionOfElements ( ITarget element ) => new QuestionMultiQueryBuilder ( element ) ;
112+
113+ /// <summary>
114+ /// Gets a performable task/question which gets a Shadow Root from the specified Shadow Host target.
115+ /// </summary>
116+ /// <remarks>
117+ /// <para>
118+ /// This is used when working with web pages which use
119+ /// <see href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM">The Shadow DOM technique</see>.
120+ /// This question allows Screenplay to 'pierce' the Shadow DOM and get the Shadow Root element, so that the Performance
121+ /// may continue and interact with elements which are inside the Shadow DOM.
122+ /// </para>
123+ /// <para>
124+ /// Note that the <see cref="SeleniumElement"/> which is returned from this question is not a fully-fledged Selenium Element.
125+ /// It may be used only to get/find elements from inside the Shadow DOM. Use with any other performables will raise
126+ /// <see cref="NotSupportedException"/>.
127+ /// </para>
128+ /// <para>
129+ /// The <see cref="ITarget"/> passed to this performable as a parameter must be the Shadow Host element, or else this question will
130+ /// throw.
131+ /// </para>
132+ /// <para>
133+ /// This technique is supported only by recent Chromium and Firefox versions, and not by Safari.
134+ /// Use <see cref="GetTheShadowRootFrom(ITarget)"/> in order to automatically select the best technique for the current web browser.
135+ /// </para>
136+ /// </remarks>
137+ /// <param name="shadowHost">The Shadow Host element, or a locator which identifies it</param>
138+ /// <returns>A performable which gets the Shadow Root.</returns>
139+ public static IPerformableWithResult < SeleniumElement > GetTheShadowRootNativelyFrom ( ITarget shadowHost )
140+ => SingleElementPerformableWithResultAdapter . From ( new GetShadowRootNatively ( ) , shadowHost ) ;
141+
142+ /// <summary>
143+ /// Gets a performable task/question which gets a Shadow Root from the specified Shadow Host target.
144+ /// </summary>
145+ /// <remarks>
146+ /// <para>
147+ /// This is used when working with web pages which use
148+ /// <see href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM">The Shadow DOM technique</see>.
149+ /// This question allows Screenplay to 'pierce' the Shadow DOM and get the Shadow Root element, so that the Performance
150+ /// may continue and interact with elements which are inside the Shadow DOM.
151+ /// </para>
152+ /// <para>
153+ /// Note that the <see cref="SeleniumElement"/> which is returned from this question is not a fully-fledged Selenium Element.
154+ /// It may be used only to get/find elements from inside the Shadow DOM. Use with any other performables will raise
155+ /// <see cref="NotSupportedException"/>.
156+ /// </para>
157+ /// <para>
158+ /// The <see cref="ITarget"/> passed to this performable as a parameter must be the Shadow Host element, or else this question will
159+ /// throw.
160+ /// </para>
161+ /// <para>
162+ /// This technique is supported only by older Chromium versions and Safari.
163+ /// Use <see cref="GetTheShadowRootFrom(ITarget)"/> in order to automatically select the best technique for the current web browser.
164+ /// </para>
165+ /// </remarks>
166+ /// <param name="shadowHost">The Shadow Host element, or a locator which identifies it</param>
167+ /// <returns>A performable which gets the Shadow Root.</returns>
168+ public static IPerformableWithResult < SeleniumElement > GetTheShadowRootWithJavaScriptFrom ( ITarget shadowHost )
169+ => SingleElementPerformableWithResultAdapter . From ( new GetShadowRootWithJavaScript ( ) , shadowHost ) ;
170+
171+ /// <summary>
172+ /// Gets a performable task/question which gets a Shadow Root from the specified Shadow Host target.
173+ /// </summary>
174+ /// <remarks>
175+ /// <para>
176+ /// This is used when working with web pages which use
177+ /// <see href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM">The Shadow DOM technique</see>.
178+ /// This question allows Screenplay to 'pierce' the Shadow DOM and get the Shadow Root element, so that the Performance
179+ /// may continue and interact with elements which are inside the Shadow DOM.
180+ /// </para>
181+ /// <para>
182+ /// Note that the <see cref="SeleniumElement"/> which is returned from this question is not a fully-fledged Selenium Element.
183+ /// It may be used only to get/find elements from inside the Shadow DOM. Use with any other performables will raise
184+ /// <see cref="NotSupportedException"/>.
185+ /// </para>
186+ /// <para>
187+ /// The <see cref="ITarget"/> passed to this performable as a parameter must be the Shadow Host element, or else this question will
188+ /// throw.
189+ /// </para>
190+ /// <para>
191+ /// Use this method to automatically select the best technique to use for the current web browser.
192+ /// This functionality is unavailable for Firefox versions 112 and below, which do not support piercing the Shadow DOM from
193+ /// Selenium.
194+ /// </para>
195+ /// </remarks>
196+ /// <param name="shadowHost">The Shadow Host element, or a locator which identifies it</param>
197+ /// <returns>A performable which gets the Shadow Root.</returns>
198+ public static IPerformableWithResult < SeleniumElement > GetTheShadowRootFrom ( ITarget shadowHost )
199+ => new GetShadowRoot ( shadowHost ) ;
109200 }
110201}
0 commit comments