o
    Ò·hú  ã                   @   sŽ   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 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 )é    )ÚDict)ÚList)ÚOptional)ÚUnion)ÚWebDriverException)ÚBy)Ú
WebElementÚtag_nameÚreturnÚ
RelativeByc                 C   s   | st dƒ‚td| iƒS )aW  Start searching for relative objects using a tag name.

    Note: This method may be removed in future versions, please use
    `locate_with` instead.
    :Args:
        - tag_name: the DOM tag of element to start searching.
    :Returns:
        - RelativeBy - use this object to create filters within a
            `find_elements` call.
    ztag_name can not be nullzcss selector)r   r   )r	   © r   ú^/var/www/html/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.

    :Args:
        - by: The value from `By` passed in.
        - using: search term to find the element with.
    :Returns:
        - RelativeBy - use this object to create filters within a
            `find_elements` call.
    NzPlease pass in a by argumentzPlease pass in a using argument)r   )r   r   r   r   r   Úlocate_with+   s   
r   c                   @   sØ   e Zd ZdZddeeeeef ef  dee	 fdd„Z
ddeeef dd fd	d
„Zddeeef dd fdd„Zddeeef dd fdd„Zddeeef dd fdd„Zddeeeef dd fdd„Zdefdd„ZdS )r   aÈ  Gives the opportunity to find elements based on their relative location
    on the page from a root elelemt. 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.

        :Args:
            root - A dict with `By` enum as the key and the search query as the value
            filters - 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__I   s   	zRelativeBy.__init__Úelement_or_locatorr
   c                 C   ó$   |st dƒ‚| j d|gdœ¡ | S )zyAdd a filter to look for elements above.

        :Args:
            - element_or_locator: Element to look above
        z:Element or locator must be given when calling above methodÚabove©ÚkindÚargs©r   r   Úappend©r   r   r   r   r   r   U   ó   zRelativeBy.abovec                 C   r   )zyAdd a filter to look for elements below.

        :Args:
            - element_or_locator: Element to look below
        z:Element or locator must be given when calling below methodÚbelowr   r   r   r   r   r   r!   a   r    zRelativeBy.belowc                 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
        z?Element or locator must be given when calling to_left_of methodÚleftr   r   r   r   r   r   Ú
to_left_ofm   r    zRelativeBy.to_left_ofc                 C   r   )zAdd a filter to look for elements right of.

        :Args:
            - element_or_locator: Element to look right of
        z@Element or locator must be given when calling to_right_of methodÚrightr   r   r   r   r   r   Úto_right_ofy   r    zRelativeBy.to_right_ofÚelement_or_locator_distancec                 C   r   )z¤Add a filter to look for elements near.

        :Args:
            - element_or_locator_distance: Element to look near by the element or within a distance
        zEElement or locator or distance must be given when calling near methodÚnearr   r   )r   r&   r   r   r   r'   …   r    zRelativeBy.nearc                 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_dict‘   s
   þÿzRelativeBy.to_dict)NN)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ústrr   r   r   r   r!   r#   r%   Úintr'   r)   r   r   r   r   r   :   s    ,N)Útypingr   r   r   r   Úselenium.common.exceptionsr   Úselenium.webdriver.common.byr   Ú$selenium.webdriver.remote.webelementr   r.   r   r   r   r   r   r   r   Ú<module>   s   