@@ -30,7 +30,7 @@ namespace OpenQA.Selenium
3030 /// <summary>
3131 /// Provides a representation of an element's shadow root.
3232 /// </summary>
33- public class ShadowRoot : ISearchContext , IWrapsDriver , IWebDriverObjectReference
33+ public class ShadowRoot : ISearchContext , IWrapsDriver , IWebDriverObjectReference , IFindsElement
3434 {
3535 /// <summary>
3636 /// The property name that represents an element shadow root in the wire protocol.
@@ -93,10 +93,21 @@ public IWebElement FindElement(By by)
9393 throw new ArgumentNullException ( nameof ( by ) , "by cannot be null" ) ;
9494 }
9595
96+ return by . FindElement ( this ) ;
97+ }
98+
99+ /// <summary>
100+ /// Finds a child element matching the given mechanism and value.
101+ /// </summary>
102+ /// <param name="mechanism">The mechanism by which to find the element.</param>
103+ /// <param name="value">The value to use to search for the element.</param>
104+ /// <returns>The first <see cref="IWebElement"/> matching the given criteria.</returns>
105+ public virtual IWebElement FindElement ( string mechanism , string value )
106+ {
96107 Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
97108 parameters . Add ( "id" , this . shadowRootId ) ;
98- parameters . Add ( "using" , by . Mechanism ) ;
99- parameters . Add ( "value" , by . Criteria ) ;
109+ parameters . Add ( "using" , mechanism ) ;
110+ parameters . Add ( "value" , value ) ;
100111
101112 Response commandResponse = this . driver . InternalExecute ( DriverCommand . FindShadowChildElement , parameters ) ;
102113 return this . driver . GetElementFromResponse ( commandResponse ) ;
@@ -117,10 +128,21 @@ public ReadOnlyCollection<IWebElement> FindElements(By by)
117128 throw new ArgumentNullException ( nameof ( by ) , "by cannot be null" ) ;
118129 }
119130
131+ return by . FindElements ( this ) ;
132+ }
133+
134+ /// <summary>
135+ /// Finds all child elements matching the given mechanism and value.
136+ /// </summary>
137+ /// <param name="mechanism">The mechanism by which to find the elements.</param>
138+ /// <param name="value">The value to use to search for the elements.</param>
139+ /// <returns>A collection of all of the <see cref="IWebElement">IWebElements</see> matching the given criteria.</returns>
140+ public virtual ReadOnlyCollection < IWebElement > FindElements ( string mechanism , string value )
141+ {
120142 Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
121143 parameters . Add ( "id" , this . shadowRootId ) ;
122- parameters . Add ( "using" , by . Mechanism ) ;
123- parameters . Add ( "value" , by . Criteria ) ;
144+ parameters . Add ( "using" , mechanism ) ;
145+ parameters . Add ( "value" , value ) ;
124146
125147 Response commandResponse = this . driver . InternalExecute ( DriverCommand . FindShadowChildElements , parameters ) ;
126148 return this . driver . GetElementsFromResponse ( commandResponse ) ;
0 commit comments