o
    N,öh1  ã                   @   s‚   d dl Z d dlmZmZmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ deddfd	d
„Zde
deddfdd„ZG dd„ dƒZdS )é    N)ÚNoReturnÚOptionalÚUnionÚoverload)ÚWebDriverException)ÚByÚByType)Ú
WebElementÚtag_nameÚreturnÚ
RelativeByc                 C   s$   t  d¡ | stdƒ‚ttj| iƒS )aê  Start searching for relative objects using a tag name.

    Parameters:
    -----------
    tag_name : str
        The DOM tag of element to start searching.

    Returns:
    --------
    RelativeBy
        Use this object to create filters within a `find_elements` call.

    Raises:
    -------
    WebDriverException
        If `tag_name` is None.

    Notes:
    ------
    - This method is deprecated and may be removed in future versions.
    - Please use `locate_with` instead.
    zbThis method is deprecated and may be removed in future versions. Please use `locate_with` instead.ztag_name can not be null)ÚwarningsÚwarnr   r   r   ÚCSS_SELECTOR)r
   © r   úw/var/www/www-root/data/www/bot.pdev.uz/venv/lib/python3.10/site-packages/selenium/webdriver/support/relative_locator.pyÚwith_tag_name   s   
r   ÚbyÚusingc                 C   s,   | dusJ dƒ‚|dusJ dƒ‚t | |iƒS )aô  Start searching for relative objects your search criteria with By.

    Parameters:
    -----------
    by : ByType
        The method to find the element.

    using : str
        The value from `By` passed in.

    Returns:
    --------
    RelativeBy
        Use this object to create filters within a `find_elements` call.

    Example:
    --------
    >>> lowest = driver.find_element(By.ID, "below")
    >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").above(lowest))
    NzPlease pass in a by argumentzPlease pass in a using argument)r   )r   r   r   r   r   Úlocate_with6   s   r   c                   @   s  e Zd ZdZeeef Zd2deeeef  dee	 fdd„Z
edeeef dd fd	d
„ƒZed3d4dd
„ƒZd3deeedf dd fdd
„Zedeeef dd fdd„ƒZed3d4dd„ƒZd3deeedf dd fdd„Zedeeef dd fdd„ƒZed3d4dd„ƒZd3deeedf dd fdd„Zedeeef dd fdd„ƒZed3d4dd„ƒZd3deeedf dd fdd„Zedeeef dd fdd„ƒZed3d4dd„ƒZd3deeedf dd fdd„Zedeeef dd fdd„ƒZed3d4d d„ƒZd3deeedf dd fd!d„Zedeeef dd fd"d#„ƒZed3d4d$d#„ƒZd3deeedf dd fd%d#„Zedeeef dd fd&d'„ƒZed3d4d(d'„ƒZd3deeedf dd fd)d'„Zed5deeef d+edd fd,d-„ƒZed6ddd+eddfd.d-„ƒZd6deeedf d+edd fd/d-„Zdefd0d1„ZdS )7r   aÓ  Gives the opportunity to find elements based on their relative location
    on the page from a root element. It is recommended that you use the helper
    function to create it.

    Example:
    --------
    >>> lowest = driver.find_element(By.ID, "below")
    >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").above(lowest))
    >>> ids = [el.get_attribute("id") for el in elements]
    >>> assert "above" in ids
    >>> assert "mid" in ids
    NÚrootÚfiltersc                 C   s   || _ |pg | _dS )aÓ  Creates a new RelativeBy object. It is preferred if you use the
        `locate_with` method as this signature could change.

        Attributes:
        -----------
        root : Dict[By, str]
            - A dict with `By` enum as the key and the search query as the value

        filters : List
            - A list of the filters that will be searched. If none are passed
                in please use the fluent API on the object to create the filters
        N©r   r   )Úselfr   r   r   r   r   Ú__init__`   s   zRelativeBy.__init__Úelement_or_locatorr   c                 C   ó   d S ©Nr   ©r   r   r   r   r   Úabovep   ó   zRelativeBy.abover   c                 C   r   r   r   r   r   r   r   r   s   r    c                 C   ó$   |st dƒ‚| j d|gdœ¡ | S )a  Add a filter to look for elements above.

        Parameters:
        -----------
        element_or_locator : Union[WebElement, Dict, None]
            Element to look above

        Returns:
        --------
        RelativeBy

        Raises:
        -------
        WebDriverException
            If `element_or_locator` is None.

        Example:
        --------
        >>> lowest = driver.find_element(By.ID, "below")
        >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").above(lowest))
        ú:Element or locator must be given when calling above methodr   ©ÚkindÚargs©r   r   Úappendr   r   r   r   r   v   ó   c                 C   r   r   r   r   r   r   r   Úbelow’   r    zRelativeBy.belowc                 C   r   r   r   r   r   r   r   r)   •   r    c                 C   r!   )a  Add a filter to look for elements below.

        Parameters:
        -----------
        element_or_locator : Union[WebElement, Dict, None]
            Element to look below

        Returns:
        --------
        RelativeBy

        Raises:
        -------
        WebDriverException
            If `element_or_locator` is None.

        Example:
        --------
        >>> highest = driver.find_element(By.ID, "high")
        >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").below(highest))
        ú:Element or locator must be given when calling below methodr)   r#   r&   r   r   r   r   r)   ˜   r(   c                 C   r   r   r   r   r   r   r   Ú
to_left_of´   r    zRelativeBy.to_left_ofc                 C   r   r   r   r   r   r   r   r+   ·   r    c                 C   r!   )a$  Add a filter to look for elements to the left of.

        Parameters:
        -----------
        element_or_locator : Union[WebElement, Dict, None]
            Element to look to the left of

        Returns:
        --------
        RelativeBy

        Raises:
        -------
        WebDriverException
            If `element_or_locator` is None.

        Example:
        --------
        >>> right = driver.find_element(By.ID, "right")
        >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").to_left_of(right))
        ú?Element or locator must be given when calling to_left_of methodÚleftr#   r&   r   r   r   r   r+   º   r(   c                 C   r   r   r   r   r   r   r   Úto_right_ofÖ   r    zRelativeBy.to_right_ofc                 C   r   r   r   r   r   r   r   r.   Ù   r    c                 C   r!   )a  Add a filter to look for elements right of.

        Parameters:
        -----------
        element_or_locator : Union[WebElement, Dict, None]
            Element to look right of

        Returns:
        --------
        RelativeBy

        Raises:
        -------
        WebDriverException
            If `element_or_locator` is None.

        Example:
        --------
        >>> left = driver.find_element(By.ID, "left")
        >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").to_right_of(left))
        ú@Element or locator must be given when calling to_right_of methodÚrightr#   r&   r   r   r   r   r.   Ü   r(   c                 C   r   r   r   r   r   r   r   Ústraight_aboveø   r    zRelativeBy.straight_abovec                 C   r   r   r   r   r   r   r   r1   û   r    c                 C   r!   )zyAdd a filter to look for elements above.

        :Args:
            - element_or_locator: Element to look above
        r"   ÚstraightAbover#   r&   r   r   r   r   r1   þ   ó   c                 C   r   r   r   r   r   r   r   Ústraight_below
  r    zRelativeBy.straight_belowc                 C   r   r   r   r   r   r   r   r4     r    c                 C   r!   )zyAdd a filter to look for elements below.

        :Args:
            - element_or_locator: Element to look below
        r*   ÚstraightBelowr#   r&   r   r   r   r   r4     r3   c                 C   r   r   r   r   r   r   r   Ústraight_left_of  r    zRelativeBy.straight_left_ofc                 C   r   r   r   r   r   r   r   r6     r    c                 C   r!   )z‹Add a filter to look for elements to the left of.

        :Args:
            - element_or_locator: Element to look to the left of
        r,   ÚstraightLeftr#   r&   r   r   r   r   r6   "  r3   c                 C   r   r   r   r   r   r   r   Ústraight_right_of.  r    zRelativeBy.straight_right_ofc                 C   r   r   r   r   r   r   r   r8   1  r    c                 C   r!   )zAdd a filter to look for elements right of.

        :Args:
            - element_or_locator: Element to look right of
        r/   ÚstraightRightr#   r&   r   r   r   r   r8   4  r3   é2   Údistancec                 C   r   r   r   ©r   r   r;   r   r   r   Únear@  r    zRelativeBy.nearc                 C   r   r   r   r<   r   r   r   r=   C  r    c                 C   s6   |st dƒ‚|dkrt dƒ‚| j d||gdœ¡ | S )až  Add a filter to look for elements near.

        Parameters:
        -----------
        element_or_locator : Union[WebElement, Dict, None]
            Element to look near by the element or within a distance

        distance : int
            Distance in pixel

        Returns:
        --------
        RelativeBy

        Raises:
        -------
        WebDriverException
            - If `element_or_locator` is None
            - If `distance` is less than or equal to 0.

        Example:
        --------
        >>> near = driver.find_element(By.ID, "near")
        >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").near(near, 50))
        z9Element or locator must be given when calling near methodr   zDistance must be positiver=   r#   r&   r<   r   r   r   r=   F  s   c                 C   s   d| j | jdœiS )z[Create a dict that will be passed to the driver to start searching
        for the element.Úrelativer   r   )r   r   r   r   Úto_dicth  s
   þÿzRelativeBy.to_dict)NNr   )r   Nr   r   )r:   )Nr:   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údictr   ÚstrÚLocatorTyper   Úlistr   r   r   r	   r   r)   r+   r.   r1   r4   r6   r8   Úintr=   r?   r   r   r   r   r   P   sd    $""")r   Útypingr   r   r   r   Úselenium.common.exceptionsr   Úselenium.webdriver.common.byr   r   Ú$selenium.webdriver.remote.webelementr	   rE   r   r   r   r   r   r   r   Ú<module>   s   