U
    g                     @   sj   d dl mZ er2d dl mZ G dd deddZnd dl mZ eeef ZG dd	 d	ZG d
d dZdS )    )TYPE_CHECKING)	TypedDictc                   @   s&   e Zd ZU eed< eed< eed< dS )JSONTimeoutsimplicitpageLoadscriptN)__name__
__module____qualname__int__annotations__ r   r   F/tmp/pip-unpacked-wheel-3ysq0mf8/selenium/webdriver/common/timeouts.pyr      s   
r   F)total)Dictc                   @   s4   e Zd ZdZdd ZedddZdddd	ZdS )
_TimeoutsDescriptorzGet or set the value of the attributes listed below.

    _implicit_wait _page_load _script

    This does not set the value on the remote end.
    c                 C   s
   || _ d S )N)name)selfr   r   r   r   __init__*   s    z_TimeoutsDescriptor.__init__returnc                 C   s   t || jd S )N  )getattrr   )r   objclsr   r   r   __get__-   s    z_TimeoutsDescriptor.__get__Nc                 C   s    t |d|}t|| j| d S )N_convert)r   setattrr   )r   r   valueZconverted_valuer   r   r   __set__0   s    z_TimeoutsDescriptor.__set__)r   r	   r
   __doc__r   floatr   r   r   r   r   r   r   "   s   r   c                   @   sX   e Zd ZdeeeddddZedZedZedZee	d	d
dZ
edddZdS )Timeoutsr   N)implicit_wait	page_loadr   r   c                 C   s(   |  || _|  || _|  || _dS )ab  Create a new Timeouts object.

        This implements https://w3c.github.io/webdriver/#timeouts.

        :Args:
         - implicit_wait - Either an int or a float. Set how many
            seconds to wait when searching for elements before
            throwing an error.
         - page_load - Either an int or a float. Set how many seconds
            to wait for a page load to complete before throwing
            an error.
         - script - Either an int or a float. Set how many seconds to
            wait for an asynchronous script to finish execution
            before throwing an error.
        N)r   _implicit_wait
_page_load_script)r   r#   r$   r   r   r   r   r   6   s    zTimeouts.__init__r%   r&   r'   )timeoutr   c                 C   s*   t |ttfrtt|d S tdd S )Nr   z&Timeouts can only be an int or a float)
isinstancer   r!   	TypeError)r   r(   r   r   r   r      s    zTimeouts._convertr   c                 C   s8   i }| j r| j |d< | jr$| j|d< | jr4| j|d< |S )Nr   r   r   )r%   r&   r'   )r   Ztimeoutsr   r   r   _to_json   s    


zTimeouts._to_json)r   r   r   )r   r	   r
   r!   r   r   r#   r$   r   r   r   r   r+   r   r   r   r   r"   5   s   r"   N)	typingr   r   r   r   strr   r   r"   r   r   r   r   <module>   s   