
    gD              
       2   d dl 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 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 dlmZ d dlmZ d dlmZ 	  e	d      Z e	d      Ze
eef   Zdedeegef   fdZdedeegef   fdZdeeef   deegef   fdZdedeegef   fdZdedeegef   fdZdedeegef   fdZ dedeegef   fdZ!deeef   deege
ed    ef   f   fd!Z"d"edeege
ed    ef   f   fd#Z#dCd"ed$ede
ed    ef   fd%Z$deeef   deegee   f   fd&Z%deeef   deegee   f   fd'Z&deeef   deege
ee   ed    f   f   fd(Z'deeef   d)edeegef   fd*Z(deeef   d)edeegef   fd+Z)deeef   d,ed)edeegef   fd-Z*de
eeef   ef   deegef   fd.Z+de
eeeef   f   deege
eef   f   fd/Z,d"e
eeeef   f   deege
eef   f   fd0Z-d1e
eeeef   f   deege
ed    ef   f   fd2Z.d"edeegef   fd3Z/d"edeegef   fd4Z0deeef   deegef   fd5Z1d"ed6edeegef   fd7Z2deeef   d6edeegef   fd8Z3d9e4deegef   fd:Z5d;ee   deegef   fd<Z6deege
eed    f   f   fd=Z7deeef   d,edeegef   fd>Z8d?eegef   deege
ed    ef   f   fd@Z9d?eege
eed    f   f   deege
ee   ed    f   f   fdAZ:d?eegef   deegef   fdBZ;y)D    N)Iterable)Any)Callable)List)Literal)Tuple)TypeVar)Union)NoAlertPresentException)NoSuchElementException)NoSuchFrameException)StaleElementReferenceExceptionWebDriverException)Alert	WebDriver)
WebElementDTtitlereturnc                       dt         f fd}|S )zAn expectation for checking the title of a page.

    title is the expected title, which must be an exact match returns
    True if the title matches, false otherwise.
    driverc                 "    | j                   k(  S Nr   r   r   s    a/var/www/html/venv/lib/python3.12/site-packages/selenium/webdriver/support/expected_conditions.py
_predicateztitle_is.<locals>._predicate7   s    ||u$$    r   r   r    s   ` r   title_isr#   0   s    %9 % r!   c                       dt         f fd}|S )zAn expectation for checking that the title contains a case-sensitive
    substring.

    title is the fragment of title expected returns True when the title
    matches, False otherwise
    r   c                      | j                   v S r   r   r   s    r   r    z"title_contains.<locals>._predicateE   s    $$r!   r   r"   s   ` r   title_containsr&   =   s    %9 % r!   locatorc                       dt         f fd}|S )zAn expectation for checking that an element is present on the DOM of a
    page. This does not necessarily mean that the element is visible.

    locator - used to find the element
    returns the WebElement once it is located
    r   c                 "     | j                    S r   )find_elementr   r'   s    r   r    z/presence_of_element_located.<locals>._predicateS   s    "v""G,,r!   WebDriverOrWebElementr'   r    s   ` r   presence_of_element_locatedr/   K   s    -0 - r!   urlc                       dt         f fd}|S )zAn expectation for checking that the current url contains a case-
    sensitive substring.

    url is the fragment of url expected, returns True when the url
    matches, False otherwise
    r   c                      | j                   v S r   current_urlr   r0   s    r   r    z url_contains.<locals>._predicatea   s    f((((r!   r   r0   r    s   ` r   url_containsr7   Y   s    )9 ) r!   patternc                       dt         f fd}|S )zAn expectation for checking the current url.

    pattern is the expected pattern.  This finds the first occurrence of
    pattern in the current url and as such does not require an exact
    full match.
    r   c                 H    t        j                  | j                        d uS r   )researchr4   )r   r8   s    r   r    zurl_matches.<locals>._predicateo   s    yy&"4"45TAAr!   r   )r8   r    s   ` r   url_matchesr=   g   s    B9 B r!   c                       dt         f fd}|S )zAn expectation for checking the current url.

    url is the expected url, which must be an exact match returns True
    if the url matches, false otherwise.
    r   c                 "    | j                   k(  S r   r3   r5   s    r   r    zurl_to_be.<locals>._predicate|       f((((r!   r   r6   s   ` r   	url_to_berA   u       )9 ) r!   c                       dt         f fd}|S )zAn expectation for checking the current url.

    url is the expected url, which must not be an exact match returns
    True if the url is different, false otherwise.
    r   c                 "    | j                   k7  S r   r3   r5   s    r   r    zurl_changes.<locals>._predicate   r@   r!   r   r6   s   ` r   url_changesrE      rB   r!   Fc                       dt         f fd}|S )a7  An expectation for checking that an element is present on the DOM of a
    page and visible. Visibility means that the element is not only displayed
    but also has a height and width that is greater than 0.

    locator - used to find the element
    returns the WebElement once it is located and visible
    r   c                 T    	 t         | j                         S # t        $ r Y yw xY wNF)_element_if_visibler*   r   r+   s    r   r    z1visibility_of_element_located.<locals>._predicate   s3    	&':v':':G'DEE- 		s    	''r,   r.   s   ` r   visibility_of_element_locatedrJ      s    0  r!   elementc                       fd}|S )a3  An expectation for checking that an element, known to be present on the
    DOM of a page, is visible.

    Visibility means that the element is not only displayed but also has
    a height and width that is greater than 0. element is the WebElement
    returns the (same) WebElement once it is visible
    c                     t              S r   )rI   _rK   s    r   r    z!visibility_of.<locals>._predicate   s    "7++r!    rK   r    s   ` r   visibility_ofrR      s    , r!   
visibilityc                 0    | j                         |k(  r| S dS rH   )is_displayed)rK   rS   s     r   rI   rI      s    **,
:7EEr!   c                       dt         f fd}|S )zAn expectation for checking that there is at least one element present
    on a web page.

    locator is used to find the element returns the list of WebElements
    once they are located
    r   c                 "     | j                    S r   )find_elementsr+   s    r   r    z4presence_of_all_elements_located.<locals>._predicate   s    #v##W--r!   r,   r.   s   ` r    presence_of_all_elements_locatedrY      s    .0 . r!   c                       dt         f fd}|S )zAn expectation for checking that there is at least one element visible
    on a web page.

    locator is used to find the element returns the list of WebElements
    once they are located
    r   c                 `     | j                    D cg c]  }t        |      s| c}S c c}w r   )rX   rI   )r   rK   r'   s     r   r    z6visibility_of_any_elements_located.<locals>._predicate   s-    ';v';';W'EfGI\]dIefffs   ++r,   r.   s   ` r   "visibility_of_any_elements_locatedr\      s    g0 g r!   c                       dt         f fd}|S )aI  An expectation for checking that all elements are present on the DOM of
    a page and visible. Visibility means that the elements are not only
    displayed but also has a height and width that is greater than 0.

    locator - used to find the elements
    returns the list of WebElements once they are located and visible
    r   c                 r    	  | j                    }|D ]  }t        |d      s y |S # t        $ r Y yw xY w)NFrS   )rX   rI   r   )r   elementsrK   r'   s      r   r    z6visibility_of_all_elements_located.<locals>._predicate   sO    	+v++W5H# !&w5A ! O- 		s   !* * * 	66r,   r.   s   ` r   "visibility_of_all_elements_locatedra      s    0  r!   text_c                 $     dt         f fd}|S )znAn expectation for checking if the given text is present in the
    specified element.

    locator, text
    r   c                 ^    	  | j                    j                  }|v S # t        $ r Y yw xY wrH   )r*   textr   r   element_textr'   rb   s     r   r    z1text_to_be_present_in_element.<locals>._predicate   s=    	.6..8==LL((- 		s     	,,r,   r'   rb   r    s   `` r   text_to_be_present_in_elementri          0  r!   c                 $     dt         f fd}|S )zlAn expectation for checking if the given text is present in the
    element's value.

    locator, text
    r   c                 h    	  | j                    j                  d      }|v S # t        $ r Y yw xY w)NvalueFr*   get_attributer   rf   s     r   r    z7text_to_be_present_in_element_value.<locals>._predicate  sB    	.6..8FFwOLL((- 		   !% 	11r,   rh   s   `` r   #text_to_be_present_in_element_valuerq          0  r!   
attribute_c                 (     dt         f fd}|S )z{An expectation for checking if the given text is present in the
    element's attribute.

    locator, attribute, text
    r   c                 n    	  | j                    j                        }|y|v S # t        $ r Y yw xY wrH   rn   )r   rg   rs   r'   rb   s     r   r    z;text_to_be_present_in_element_attribute.<locals>._predicate  sK    	.6..8FFzRL#L((- 		s    ( ( 	44r,   )r'   rs   rb   r    s   ``` r   'text_to_be_present_in_element_attributerv     s    0  r!   c                       dt         f fd}|S )zAn expectation for checking whether the given frame is available to
    switch to.

    If the frame is available it switches the given driver to the
    specified frame.
    r   c                     	 t        t              r9t        t              s)| j                  j	                   | j
                          y| j                  j	                         y# t        $ r Y yw xY w)NTF)
isinstancer   str	switch_toframer*   r   r+   s    r   r    z:frame_to_be_available_and_switch_to_it.<locals>._predicate+  sm    	'8,Z5M  &&':v':':G'DE    &&w/# 		s   AA( A( (	A43A4r   r.   s   ` r   &frame_to_be_available_and_switch_to_itr}   #  s    9  r!   c                       dt         f fd}|S )zAn Expectation for checking that an element is either invisible or not
    present on the DOM.

    locator used to find the element
    r   c                     	 }t        |t              s | j                  | }t        |d      S # t        t
        f$ r Y yw xY w)NFr_   T)ry   r   r*   rI   r   r   )r   targetr'   s     r   r    z3invisibility_of_element_located.<locals>._predicateA  sP    	Ffj1,,,f5&v%@@&(FG 	 	s   -1 AAr,   r.   s   ` r   invisibility_of_element_locatedr   8  s    0  r!   c                     t        |       S )zAn Expectation for checking that an element is either invisible or not
    present on the DOM.

    element is either a locator (text) or an WebElement
    )r   )rK   s    r   invisibility_of_elementr   R  s     +733r!   markc                       dt         f fd}|S )zAn Expectation for checking an element is visible and enabled such that
    you can click it.

    element is either a locator (text) or an WebElement
    r   c                     }t        |t              s | j                  | } t        |      |       }|r|j	                         r|S yrH   )ry   r   r*   rR   
is_enabled)r   r   rK   r   s      r   r    z+element_to_be_clickable.<locals>._predicateh  sK    &*-(V((&1F'-'/w))+Nr!   r,   )r   r    s   ` r   element_to_be_clickabler   ]  s    0  r!   c                       fd}|S )zWait until an element is no longer attached to the DOM.

    element is the element to wait for. returns False if the element is
    still attached to the DOM, true otherwise.
    c                 F    	 j                          y# t        $ r Y yw xY wNFT)r   r   rN   s    r   r    z staleness_of.<locals>._predicate{  s)    	 - 		s    	  rP   rQ   s   ` r   staleness_ofr   t  s     r!   c                       fd}|S )z]An expectation for checking the selection is selected.

    element is WebElement object
    c                 $    j                         S r   is_selectedrN   s    r   r    z*element_to_be_selected.<locals>._predicate  s    ""$$r!   rP   rQ   s   ` r   element_to_be_selectedr     s    % r!   c                       dt         f fd}|S )zdAn expectation for the element to be located is selected.

    locator is a tuple of (by, path)
    r   c                 >     | j                    j                         S r   )r*   r   r+   s    r   r    z2element_located_to_be_selected.<locals>._predicate  s    "v""G,88::r!   r,   r.   s   ` r   element_located_to_be_selectedr     s    ;0 ; r!   r   c                       fd}|S )z~An expectation for checking if the given element is selected.

    element is WebElement object is_selected is a Boolean.
    c                 *    j                         k(  S r   r   )rO   rK   r   s    r   r    z1element_selection_state_to_be.<locals>._predicate  s    ""$33r!   rP   )rK   r   r    s   `` r   element_selection_state_to_ber     s    4 r!   c                 $     dt         f fd}|S )zAn expectation to locate an element and check if the selection state
    specified is in that state.

    locator is a tuple of (by, path) is_selected is a boolean
    r   c                 h    	  | j                    }|j                         k(  S # t        $ r Y yw xY wrH   )r*   r   r   )r   rK   r   r'   s     r   r    z9element_located_selection_state_to_be.<locals>._predicate  s@    	)f))73G&&(K77- 		rp   r,   )r'   r   r    s   `` r   %element_located_selection_state_to_ber     rr   r!   num_windowsc                       dt         f fd}|S )z?An expectation for the number of windows to be a certain value.r   c                 4    t        | j                        k(  S r   lenwindow_handles)r   r   s    r   r    z+number_of_windows_to_be.<locals>._predicate  s    6(()[88r!   r   )r   r    s   ` r   number_of_windows_to_ber     s    99 9 r!   current_handlesc                       dt         f fd}|S )zdAn expectation that a new window will be opened and have the number of
    windows handles increase.r   c                 F    t        | j                        t              kD  S r   r   )r   r   s    r   r    z(new_window_is_opened.<locals>._predicate  s    6(()C,@@@r!   r   )r   r    s   ` r   new_window_is_openedr     s    A9 A r!   c                      dt         fd} | S )zUAn expectation for checking if an alert is currently present and
    switching to it.r   c                 N    	 | j                   j                  S # t        $ r Y yw xY wrH   )r{   alertr   )r   s    r   r    z$alert_is_present.<locals>._predicate  s+    	##)))& 		s    	$$r   )r    s    r   alert_is_presentr     s    9  r!   c                 $     dt         f fd}|S )zyAn expectation for checking if the given attribute is included in the
    specified element.

    locator, attribute
    r   c                 h    	  | j                    j                        }|d uS # t        $ r Y yw xY wrH   rn   )r   element_attributers   r'   s     r   r    z0element_attribute_to_include.<locals>._predicate  sC    	 3 3 3W = K KJ W$D00- 		rp   r,   )r'   rs   r    s   `` r   element_attribute_to_includer     rj   r!   expected_conditionsc                        dt         f fd}|S )zAn expectation that any of multiple expected conditions is true.

    Equivalent to a logical 'OR'. Returns results of the first matching
    condition, or False if none do.
    r   c                 P    D ]  }	  ||       }|r|c S  y# t         $ r Y  w xY wrH   r   r   expected_conditionresultr   s      r   any_of_conditionz any_of.<locals>.any_of_condition  sH    "5 	+F3!M 	  & s   	%%r   )r   r   s   ` r   any_ofr     s      r!   c                        dt         f fd}|S )a   An expectation that all of multiple expected conditions is true.

    Equivalent to a logical 'AND'.
    Returns: When any ExpectedCondition is not met: False.
    When all ExpectedConditions are met: A List with each ExpectedCondition's return value.
    r   c                 v    g }D ]   }	  ||       }|s y|j                  |       " |S # t        $ r Y  yw xY wrH   )appendr   )r   resultsr   r   r   s       r   all_of_conditionz all_of.<locals>.all_of_condition  sT    "5 	+F3 v&	  & s   
++	88r   )r   r   s   ` r   all_ofr     s    
 
 r!   c                        dt         f fd}|S )zAn expectation that none of 1 or multiple expected conditions is true.

    Equivalent to a logical 'NOT-OR'. Returns a Boolean
    r   c                 L    D ]  }	  ||       }|r y y# t         $ r Y w xY wr   r   r   s      r   none_of_conditionz"none_of.<locals>.none_of_condition!  sF    "5 	+F3  	  & s   
	##r   )r   r   s   ` r   none_ofr     s    !  r!   )T)<r;   collections.abcr   typingr   r   r   r   r   r	   r
   selenium.common.exceptionsr   r   r   r   r   selenium.webdriver.common.alertr   #selenium.webdriver.remote.webdriverr   r   r   r   r-   rz   boolr#   r&   r/   r7   r=   rA   rE   rJ   rR   rI   rY   r\   ra   ri   rq   rv   r}   r   r   r   r   r   r   r   r   intr   r   r   r   r   r   r   rP   r!   r   <module>r      s  $ 
 $        > = ; E 9 1 9 :
 CLCLi34 
C 
Hi[$%67 
# (I;+<"= sCx XG\F]_iFi=j c h	{D'89  9+t*;!< 
3 
8YK$56 

S 
Xyk4&78 
38_$%uWU^Z-G'HHI(: (C5%PZ@Z:[3[*\ F F FwW\~_iOiIj FeCHo (LaKbdhisdtKtBu c3h HNcMdfjkufvMvDw 38_$%uT*-=wu~-M'NNO05c? 3 8UjTkmqTqKr "38_%($%t+,&38_*-69$%t+,*E%S/3:N4O T\^g]hjn]nTo *:uS#X./$%uZ-='>>?44:uS#X./4$%uZ-='>>?4

E#s(O+
,$%uWU^Z-G'HHI.* 3%+)> $	J 	8SE4K3H 		E#s(O 	J_I`bfIf@g 		: 	D 	XWZV[]aVaMb 	38_+/$%t+,& 9+t:K1L $s) )dAR8S 
(I;eWU^6K0L#LM 
%S/ s xYnXoquXuOv "1#q&!1 hsE'RW.Z[J[D\?\6] ("A3a.?(@#@Aqc5a'%.01122(A38"4 1#t)9L r!   