1616# under the License. 
1717
1818from  hashlib  import  md5  as  md5_hash 
19+ from  typing  import  List , Optional , Union 
1920
20- from  ..common .by  import  By 
21+ from  ..common .by  import  By ,  ByType 
2122from  .command  import  Command 
23+ from  .webelement  import  WebElement 
24+ from  ..support .relative_locator  import  RelativeBy 
2225
2326
2427class  ShadowRoot :
@@ -39,12 +42,16 @@ def __repr__(self) -> str:
3942            type (self ), self .session .session_id , self ._id 
4043        )
4144
42-     def  find_element (self , by : str  =  By .ID , value : str  =  None ):
45+     @property  
46+     def  id (self ) ->  str :
47+         return  self ._id 
48+ 
49+     def  find_element (self , by : Union [ByType , RelativeBy ] =  By .ID , value : Optional [str ] =  None ) ->  WebElement :
4350        """Find an element inside a shadow root given a By strategy and 
4451        locator. 
4552
4653        Parameters: 
47-         ---------- 
54+         -----------  
4855        by : selenium.webdriver.common.by.By 
4956            The locating strategy to use. Default is `By.ID`. Supported values include: 
5057            - By.ID: Locate by element ID. 
@@ -78,11 +85,11 @@ def find_element(self, by: str = By.ID, value: str = None):
7885
7986        return  self ._execute (Command .FIND_ELEMENT_FROM_SHADOW_ROOT , {"using" : by , "value" : value })["value" ]
8087
81-     def  find_elements (self , by : str   =  By .ID , value : str  =  None ):
88+     def  find_elements (self , by : Union [ ByType ,  RelativeBy ]  =  By .ID , value : Optional [ str ]  =  None )  ->   List [ WebElement ] :
8289        """Find elements inside a shadow root given a By strategy and locator. 
8390
8491        Parameters: 
85-         ---------- 
92+         -----------  
8693        by : selenium.webdriver.common.by.By 
8794            The locating strategy to use. Default is `By.ID`. Supported values include: 
8895            - By.ID: Locate by element ID. 
@@ -97,11 +104,11 @@ def find_elements(self, by: str = By.ID, value: str = None):
97104
98105        Example: 
99106        -------- 
100-         element = driver.find_element (By.ID, 'foo') 
107+         element = driver.find_elements (By.ID, 'foo') 
101108
102109        Returns: 
103110        ------- 
104-         WebElement 
111+         List[ WebElement]  
105112            list of `WebElements` matching locator strategy found on the page. 
106113        """ 
107114        if  by  ==  By .ID :
0 commit comments