B
     ¸hæ  ã               @   s>   d dl Z d dlmZ d dlmZ dZefZG dd„ deƒZdS )é    N)ÚNoSuchElementException)ÚTimeoutExceptiong      à?c               @   s6   e Zd Zedfdd„Zdd„ Zddd„Zdd	d
„ZdS )ÚWebDriverWaitNc             C   sr   || _ || _|| _| jdkr"t| _ttƒ}|dk	rdy| t|ƒ¡ W n tk
rb   | 	|¡ Y nX t
|ƒ| _dS )ad  Constructor, takes a WebDriver instance and timeout in seconds.

           :Args:
            - driver - Instance of WebDriver (Ie, Firefox, Chrome or Remote)
            - timeout - Number of seconds before timing out
            - poll_frequency - sleep interval between calls
              By default, it is 0.5 second.
            - ignored_exceptions - iterable structure of exception classes ignored during calls.
              By default, it contains NoSuchElementException only.

           Example:
            from selenium.webdriver.support.ui import WebDriverWait 

            element = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_id("someId")) 

            is_disappeared = WebDriverWait(driver, 30, 1, (ElementNotVisibleException)).\ 

                        until_not(lambda x: x.find_element_by_id("someId").is_displayed())
        r   N)Ú_driverÚ_timeoutÚ_pollÚPOLL_FREQUENCYÚlistÚIGNORED_EXCEPTIONSÚextendÚiterÚ	TypeErrorÚappendÚtupleÚ_ignored_exceptions)ÚselfÚdriverÚtimeoutZpoll_frequencyZignored_exceptionsÚ
exceptions© r   ú\C:\Users\sanjo\AppData\Local\Qlobot\Launcher\ext_packages\selenium\webdriver\support\wait.pyÚ__init__   s    
zWebDriverWait.__init__c             C   s   d  t| ƒ| jj¡S )Nz-<{0.__module__}.{0.__name__} (session="{1}")>)ÚformatÚtyper   Ú
session_id)r   r   r   r   Ú__repr__:   s    zWebDriverWait.__repr__Ú c          
   C   sš   d}d}t   ¡ | j }xry|| jƒ}|r,|S W n< | jk
rj } zt|ddƒ}t|ddƒ}W dd}~X Y nX t  | j¡ t   ¡ |krP qW t|||ƒ‚dS )zeCalls the method provided with the driver as an argument until the         return value is not False.NÚscreenÚ
stacktrace)Útimer   r   r   ÚgetattrÚsleepr   r   )r   ÚmethodÚmessager   r   Úend_timeÚvalueÚexcr   r   r   Úuntil>   s    
zWebDriverWait.untilc             C   sh   t   ¡ | j }xLy|| jƒ}|s$|S W n | jk
r<   dS X t  | j¡ t   ¡ |krP qW t|ƒ‚dS )zaCalls the method provided with the driver as an argument until the         return value is False.TN)r   r   r   r   r!   r   r   )r   r"   r#   r$   r%   r   r   r   Ú	until_notR   s    
zWebDriverWait.until_not)r   )r   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r'   r(   r   r   r   r   r      s   
r   )r   Úselenium.common.exceptionsr   r   r   r
   Úobjectr   r   r   r   r   Ú<module>   s
   