a
    .c                     @   sl   d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 e
ddddZee
dd	d
dZG dd dZdS )    )DictListUnion)WebDriverException)By)
WebElement
RelativeBy)tag_namereturnc                 C   s   | st dtd| iS )a|  
        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   e/var/www/brookimports/venv/lib/python3.9/site-packages/selenium/webdriver/support/relative_locator.pywith_tag_name   s    r   )byusingr
   c                 C   s,   | dusJ d|dus J dt | |iS )aJ  
        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eeef edddZde	e
ef d dddZde	e
ef d dd	d
Zde	e
ef d dddZde	e
ef d dddZde	e
eef d dddZed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
        Nr   )selfr   r   r   r   r   __init__J   s    	zRelativeBy.__init__)element_or_locatorr
   c                 C   s$   |st d| jd|gd | S )z
            Add a filter to look for elements above.
            :Args:
                - element_or_locator: Element to look above
        :Element or locator must be given when calling above methodabovekindargsr   r   appendr   r   r   r   r   r   V   s    zRelativeBy.abovec                 C   s$   |st d| jd|gd | S )z
            Add a filter to look for elements below.
            :Args:
                - element_or_locator: Element to look below
        r   belowr   r   r   r   r   r   r   b   s    zRelativeBy.belowc                 C   s$   |st d| jd|gd | S )z
            Add a filter to look for elements to the left of.
            :Args:
                - element_or_locator: Element to look to the left of
        r   leftr   r   r   r   r   r   
to_left_ofn   s    zRelativeBy.to_left_ofc                 C   s$   |st d| jd|gd | S )z
            Add a filter to look for elements right of.
            :Args:
                - element_or_locator: Element to look right of
        r   rightr   r   r   r   r   r   to_right_ofz   s    zRelativeBy.to_right_of)element_or_locator_distancer
   c                 C   s$   |st d| jd|gd | S )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
        zFElement or locator or distance must be given when calling above methodnearr   r   )r   r$   r   r   r   r%      s    zRelativeBy.near)r
   c                 C   s   d| j | jdiS )zh
            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)N)N)N)N)__name__
__module____qualname____doc__r   r   strr   r   r   r   r   r   r!   r#   intr%   r'   r   r   r   r   r   :   s   N)typingr   r   r   Zselenium.common.exceptionsr   Zselenium.webdriver.common.byr   Z$selenium.webdriver.remote.webelementr   r,   r   r   r   r   r   r   r   <module>   s   