o
    ѷ6i                     @   s   U d dl Z d dlmZ d dlmZmZmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ dZeed	< e	fZeee  ed
< edeeef dZedZG dd dee ZdS )    N)Callable)GenericLiteralTypeVarUnion)NoSuchElementExceptionTimeoutException)WaitExcTypes)	WebDriver)
WebElementg      ?POLL_FREQUENCYIGNORED_EXCEPTIONSD)boundTc                
   @   s   e Zd ZedfdededededB fddZdefd	d
Z	dde
eged eB f dedefddZdde
egef dedeed B fddZdS )WebDriverWaitNdrivertimeoutpoll_frequencyignored_exceptionsc                 C   sp   || _ t|| _|| _| jdkrt| _tt}|r1z	|t| W n t	y0   |
| Y nw t|| _dS )a  Constructor, takes a WebDriver instance and timeout in seconds.

        Args:
            driver: Instance of WebDriver (Ie, Firefox, Chrome or Remote) or
                a WebElement.
            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.common.by import By
            >>> from selenium.webdriver.support.wait import WebDriverWait
            >>> from selenium.common.exceptions import ElementNotVisibleException
            >>>
            >>> # Wait until the element is no longer visible
            >>> is_disappeared = WebDriverWait(driver, 30, 1, (ElementNotVisibleException))
            ...     .until_not(lambda x: x.find_element(By.ID, "someId").is_displayed())
        r   N)_driverfloat_timeout_pollr   listr   extenditer	TypeErrorappendtuple_ignored_exceptions)selfr   r   r   r   
exceptions r#   d/var/www/hoanhtaovolam_webdjango/env/lib/python3.10/site-packages/selenium/webdriver/support/wait.py__init__#   s   

zWebDriverWait.__init__returnc                 C   s(   dt | j dt | j d| jj dS )N<.z (session="z")>)type
__module____name__r   
session_id)r!   r#   r#   r$   __repr__L   s   (zWebDriverWait.__repr__ methodFmessagec              
   C   s   d}d}t  | j }	 z|| j}|r|W S W n | jy7 } zt|dd}t|dd}W Y d}~nd}~ww t  |kr?nt | j qt|||)a7  Wait until the method returns a value that is not False.

        Calls the method provided with the driver as an argument until the
        return value does not evaluate to ``False``.

        Args:
            method: A callable object that takes a WebDriver instance as an
                argument.
            message: Optional message for TimeoutException.

        Returns:
            The result of the last call to `method`.

        Raises:
            TimeoutException: If 'method' does not return a truthy value within
                the WebDriverWait object's timeout.

        Example:
            >>> from selenium.webdriver.common.by import By
            >>> from selenium.webdriver.support.ui import WebDriverWait
            >>> from selenium.webdriver.support import expected_conditions as EC
            >>>
            >>> # Wait until an element is visible on the page
            >>> wait = WebDriverWait(driver, 10)
            >>> element = wait.until(EC.visibility_of_element_located((By.ID, "exampleId")))
            >>> print(element.text)
        NTscreen
stacktrace)	time	monotonicr   r   r    getattrsleepr   r   )r!   r/   r0   r1   r2   end_timevalueexcr#   r#   r$   untilO   s&   
zWebDriverWait.untilTc                 C   sd   t  | j }	 z|| j}|s|W S W n | jy   Y dS w t  |kr+	 t|t | j q)a  Wait until the method returns a value that is False.

        Calls the method provided with the driver as an argument until the
        return value evaluates to ``False``.

        Args:
            method: A callable object that takes a WebDriver instance as an
                argument.
            message: Optional message for TimeoutException.

        Returns:
            The result of the last call to `method`.

        Raises:
            TimeoutException: If 'method' does not return False within the
                WebDriverWait object's timeout.

        Example:
            >>> from selenium.webdriver.common.by import By
            >>> from selenium.webdriver.support.ui import WebDriverWait
            >>> from selenium.webdriver.support import expected_conditions as EC
            >>>
            >>> # Wait until an element is no longer visible on the page
            >>> wait = WebDriverWait(driver, 10)
            >>> is_disappeared = wait.until_not(EC.visibility_of_element_located((By.ID, "exampleId")))
        T)r3   r4   r   r   r    r6   r   r   )r!   r/   r0   r7   r8   r#   r#   r$   	until_not|   s   
zWebDriverWait.until_not)r.   )r+   r*   __qualname__r   r   r   r	   r%   strr-   r   r   r   r:   r;   r#   r#   r#   r$   r   "   s    
)*.-r   )r3   collections.abcr   typingr   r   r   r   selenium.common.exceptionsr   r   selenium.typesr	   #selenium.webdriver.remote.webdriverr
   $selenium.webdriver.remote.webelementr   r   r   __annotations__r   r   r)   	Exceptionr   r   r   r#   r#   r#   r$   <module>   s   
