a
    5ñ»jÔ  ã                   @   s6   d dl mZ ddlmZ ddlmZ G dd„ dƒZdS )	é    )Úmd5é   )ÚByé   )ÚCommandc                   @   s~   e Zd Zddœdd„Zedœdd„Zedœdd„Zedœd	d
„Z	e
jdfeedœdd„Ze
jdfeedœdd„Zddd„ZdS )Ú
ShadowRootN)Úreturnc                 C   s   || _ || _d S ©N)ÚsessionÚ_id)Úselfr
   Zid_© r   úJE:\soccer\ml_env\Lib\site-packages\selenium/webdriver/remote/shadowroot.pyÚ__init__   s    zShadowRoot.__init__c                 C   s   | j |j kS r	   )r   )r   Zother_shadowrootr   r   r   Ú__eq__   s    zShadowRoot.__eq__c                 C   s   t t| j d¡ƒ ¡ dƒS )Nzutf-8é   )ÚintÚmd5_hashr   ÚencodeÚ	hexdigest©r   r   r   r   Ú__hash__"   s    zShadowRoot.__hash__c                 C   s   d  t| ƒ| jj| j¡S )Nz<<{0.__module__}.{0.__name__} (session="{1}", element="{2}")>)ÚformatÚtyper
   Z
session_idr   r   r   r   r   Ú__repr__%   s    ÿzShadowRoot.__repr__)ÚbyÚvaluec                 C   sn   |t jkrt j}d|› d�}n8|t jkr:t j}d|› �}n|t jkrVt j}d|› d�}|  tj||dœ¡d S )a  Find an element inside a shadow root given a By strategy and
        locator.

        Parameters:
        -----------
        by : selenium.webdriver.common.by.By
            The locating strategy to use. Default is `By.ID`. Supported values include:
            - By.ID: Locate by element ID.
            - By.NAME: Locate by the `name` attribute.
            - By.XPATH: Locate by an XPath expression.
            - By.CSS_SELECTOR: Locate by a CSS selector.
            - By.CLASS_NAME: Locate by the `class` attribute.
            - By.TAG_NAME: Locate by the tag name (e.g., "input", "button").
            - By.LINK_TEXT: Locate a link element by its exact text.
            - By.PARTIAL_LINK_TEXT: Locate a link element by partial text match.
            - RelativeBy: Locate elements relative to a specified root element.

        Example:
        --------
        element = driver.find_element(By.ID, 'foo')

        Returns:
        -------
        WebElement
            The first matching `WebElement` found on the page.
        ú[id="ú"]Ú.ú[name="©Úusingr   r   )r   ÚIDÚCSS_SELECTORÚ
CLASS_NAMEÚNAMEÚ_executer   ZFIND_ELEMENT_FROM_SHADOW_ROOT©r   r   r   r   r   r   Úfind_element*   s    


zShadowRoot.find_elementc                 C   sn   |t jkrt j}d|› d�}n8|t jkr:t j}d|› �}n|t jkrVt j}d|› d�}|  tj||dœ¡d S )a  Find elements inside a shadow root given a By strategy and locator.

        Parameters:
        -----------
        by : selenium.webdriver.common.by.By
            The locating strategy to use. Default is `By.ID`. Supported values include:
            - By.ID: Locate by element ID.
            - By.NAME: Locate by the `name` attribute.
            - By.XPATH: Locate by an XPath expression.
            - By.CSS_SELECTOR: Locate by a CSS selector.
            - By.CLASS_NAME: Locate by the `class` attribute.
            - By.TAG_NAME: Locate by the tag name (e.g., "input", "button").
            - By.LINK_TEXT: Locate a link element by its exact text.
            - By.PARTIAL_LINK_TEXT: Locate a link element by partial text match.
            - RelativeBy: Locate elements relative to a specified root element.

        Example:
        --------
        element = driver.find_elements(By.ID, 'foo')

        Returns:
        -------
        List[WebElement]
            list of `WebElements` matching locator strategy found on the page.
        r   r   r   r    r!   r   )r   r#   r$   r%   r&   r'   r   ZFIND_ELEMENTS_FROM_SHADOW_ROOTr(   r   r   r   Úfind_elementsQ   s    


zShadowRoot.find_elementsc                 C   s    |si }| j |d< | j ||¡S )a9  Executes a command against the underlying HTML element.

        Args:
          command: The name of the command to _execute as a string.
          params: A dictionary of named parameters to send with the command.

        Returns:
          The command's JSON response loaded into a dictionary object.
        ZshadowId)r   r
   Úexecute)r   ÚcommandÚparamsr   r   r   r'   x   s    

zShadowRoot._execute)N)Ú__name__Ú
__module__Ú__qualname__r   Úboolr   r   r   Ústrr   r   r#   r)   r*   r'   r   r   r   r   r      s   ''r   N)Úhashlibr   r   Z	common.byr   r,   r   r   r   r   r   r   Ú<module>   s   