o
    衡i[                     @  sj   d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ er,d dlmZ G dd	 d	Zd
S )    )annotations)md5)TYPE_CHECKING)InvalidSelectorException)By)Command)
WebElementc                   @  sp   e Zd ZdddZdddZdd	d
ZdddZedddZe	j
dfd ddZe	j
dfd!ddZd"ddZdS )#
ShadowRootreturnNonec                 C  s   || _ || _d S N)session_id)selfr   id_ r   u/var/www/html/asbeauty/laura_geller_scraping/env/lib/python3.10/site-packages/selenium/webdriver/remote/shadowroot.py__init__$   s   
zShadowRoot.__init__boolc                 C  s   | j |j kS r   r   )r   other_shadowrootr   r   r   __eq__(   s   zShadowRoot.__eq__intc                 C  s   t t| jd dS )Nzutf-8   )r   md5_hashr   encode	hexdigestr   r   r   r   __hash__+   s   zShadowRoot.__hash__strc                 C  s   d t| | jj| jS )Nz<<{0.__module__}.{0.__name__} (session="{1}", element="{2}")>)formattyper   
session_idr   r   r   r   r   __repr__.   s   zShadowRoot.__repr__c                 C  s   | j S r   r   r   r   r   r   id3   s   zShadowRoot.idNbyvalue
str | Noner   c                 C     |t jkrt j}d| d}n-|t jkr.|r%tdd | D r%tdt j}d| }n|t jkr<t j}d| d}| t	j
||dd	 S )
a  Find an element inside a shadow root given a By strategy and locator.

        Args:
            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.
            value: The locator value to use with the specified `by` strategy.

        Returns:
            The first matching `WebElement` found on the page.

        Example:
            >>> element = driver.find_element(By.ID, "foo")
        [id=""]c                 s      | ]}|  V  qd S r   isspace.0charr   r   r   	<genexpr>P       z*ShadowRoot.find_element.<locals>.<genexpr>%Compound class names are not allowed..[name="usingr&   r&   )r   IDCSS_SELECTOR
CLASS_NAMEanystripr   NAME_executer   FIND_ELEMENT_FROM_SHADOW_ROOTr   r%   r&   r   r   r   find_element7      


zShadowRoot.find_elementlist[WebElement]c                 C  r(   )
a  Find elements inside a shadow root given a By strategy and locator.

        Args:
            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.
            value: The locator value to use with the specified `by` strategy.

        Returns:
            List of `WebElements` matching locator strategy found on the page.

        Example:
            >>> element = driver.find_elements(By.ID, "foo")
        r)   r*   c                 s  r+   r   r,   r.   r   r   r   r1   s   r2   z+ShadowRoot.find_elements.<locals>.<genexpr>r3   r4   r5   r6   r&   )r   r8   r9   r:   r;   r<   r   r=   r>   r   FIND_ELEMENTS_FROM_SHADOW_ROOTr@   r   r   r   find_elementsZ   rB   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.
        shadowId)r   r   execute)r   commandparamsr   r   r   r>   ~   s   

zShadowRoot._execute)r
   r   )r
   r   )r
   r   )r
   r   )r%   r   r&   r'   r
   r   )r%   r   r&   r'   r
   rC   r   )__name__
__module____qualname__r   r   r   r#   propertyr$   r   r8   rA   rE   r>   r   r   r   r   r	   !   s    



#$r	   N)
__future__r   hashlibr   r   typingr   selenium.common.exceptionsr   selenium.webdriver.common.byr   !selenium.webdriver.remote.commandr   $selenium.webdriver.remote.webelementr   r	   r   r   r   r   <module>   s   