
    $)f;+                         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	  G d de
e      Z G d	 d
      Z G d d      Z G d d      Z G d d      Z G d d      Z G d de      Z G d de      Zy)    N)ABCMeta)abstractmethod)Enum)InvalidArgumentException)Proxyc                       e Zd ZdZdZdZdZy)PageLoadStrategya  Enum of possible page load strategies.

    Selenium support following strategies:
        * normal (default) - waits for all resources to download
        * eager - DOM access is ready, but other resources like images may still be loading
        * none - does not block `WebDriver` at all

    Docs: https://www.selenium.dev/documentation/webdriver/drivers/options/#pageloadstrategy.
    normaleagernoneN)__name__
__module____qualname____doc__r
   r   r        ^/var/www/html/flask-app/venv/lib/python3.12/site-packages/selenium/webdriver/common/options.pyr	   r	      s     FEDr   r	   c                       e Zd Zd Zd Zd Zy)_BaseOptionsDescriptorc                     || _         y Nnameselfr   s     r   __init__z_BaseOptionsDescriptor.__init__+   	    	r   c                     | j                   dv r&|j                  j                  | j                   d      S |j                  j                  | j                         S )N)acceptInsecureCertsstrictFileInteractabilitysetWindowRectse:downloadsEnabledF)r   _capsgetr   objclss      r   __get__z_BaseOptionsDescriptor.__get__.   s?    99tt99==E22yy}}TYY''r   c                 <    |j                  | j                  |       y r   )set_capabilityr   r   r&   values      r   __set__z_BaseOptionsDescriptor.__set__3   s    499e,r   N)r   r   r   r   r(   r-   r   r   r   r   r   *   s    (
-r   r   c                   "    e Zd ZdZd Zd Zd Zy)_PageLoadStrategyDescriptorzDetermines the point at which a navigation command is returned:
    https://w3c.github.io/webdriver/#dfn-table-of-page-load-strategies.

    :param strategy: the strategy corresponding to a document readiness state
    c                     || _         y r   r   r   s     r   r   z$_PageLoadStrategyDescriptor.__init__>   r   r   c                 L    |j                   j                  | j                        S r   r#   r$   r   r%   s      r   r(   z#_PageLoadStrategyDescriptor.__get__A       yy}}TYY''r   c                 Z    |dv r|j                  | j                  |       y t        d      )N)r
   r   r   z>Strategy can only be one of the following: normal, eager, noner*   r   
ValueErrorr+   s      r   r-   z#_PageLoadStrategyDescriptor.__set__D   s+    //tyy%0]^^r   Nr   r   r   r   r   r(   r-   r   r   r   r/   r/   7   s    (_r   r/   c                   "    e Zd ZdZd Zd Zd Zy)"_UnHandledPromptBehaviorDescriptorad  How the driver should respond when an alert is present and the:
    command sent is not handling the alert:
    https://w3c.github.io/webdriver/#dfn-table-of-page-load-strategies:

    :param behavior: behavior to use when an alert is encountered

    :returns: Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)
    c                     || _         y r   r   r   s     r   r   z+_UnHandledPromptBehaviorDescriptor.__init__U   r   r   c                 L    |j                   j                  | j                        S r   r2   r%   s      r   r(   z*_UnHandledPromptBehaviorDescriptor.__get__X   r3   r   c                 Z    |dv r|j                  | j                  |       y t        d      )N)dismissacceptzdismiss and notifyzaccept and notifyignoreziBehavior can only be one of the following: dismiss, accept, dismiss and notify, accept and notify, ignorer5   r+   s      r   r-   z*_UnHandledPromptBehaviorDescriptor.__set__[   s1    ^^tyy%0, r   Nr7   r   r   r   r9   r9   K   s    (r   r9   c                   "    e Zd ZdZd Zd Zd Zy)_TimeoutsDescriptoraL  How long the driver should wait for actions to complete before:
    returning an error https://w3c.github.io/webdriver/#timeouts:

    :param timeouts: values in milliseconds for implicit wait, page load and script timeout

    :returns: Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)
    c                     || _         y r   r   r   s     r   r   z_TimeoutsDescriptor.__init__n   r   r   c                 L    |j                   j                  | j                        S r   r2   r%   s      r   r(   z_TimeoutsDescriptor.__get__q   r3   r   c                     t        d |j                         D              r|j                  | j                  |       y t	        d      )Nc              3   $   K   | ]  }|d v  
 yw))implicitpageLoadscriptNr   ).0xs     r   	<genexpr>z._TimeoutsDescriptor.__set__.<locals>.<genexpr>u   s     M1q66Ms   zITimeout keys can only be one of the following: implicit, pageLoad, script)allkeysr*   r   r6   r+   s      r   r-   z_TimeoutsDescriptor.__set__t   s6    M

MMtyy%0hiir   Nr7   r   r   r   rA   rA   e   s    (jr   rA   c                   "    e Zd ZdZd Zd Zd Zy)_ProxyDescriptorz':Returns: Proxy if set, otherwise None.c                     || _         y r   r   r   s     r   r   z_ProxyDescriptor.__init__~   r   r   c                     |j                   S r   )_proxyr%   s      r   r(   z_ProxyDescriptor.__get__   s    zzr   c                     t        |t              st        d      ||_        |j	                         |j
                  | j                  <   y )Nz$Only Proxy objects can be passed in.)
isinstancer   r   rR   to_capabilitiesr#   r   r+   s      r   r-   z_ProxyDescriptor.__set__   s:    %'*+QRR
$446		$))r   Nr7   r   r   r   rO   rO   {   s    17r   rO   c            	           e Zd ZdZ ed      Z	  ed      Z	  ed      Z	  ed      Z	  ed      Z		  e
d      Z	  ed      Z	  ed	      Z	  ed
      Z	  ed      Z	 d fdZed        ZddZ	 	 	 ddej0                  e   dej0                  e   dej0                  e   ddfdZed        Zeed               Z xZS )BaseOptionsz*Base class for individual browser options.browserVersionplatformNamer   r    r!   pageLoadStrategyunhandledPromptBehaviortimeoutsproxyr"   returnNc                     t         |           | j                  | _        d | _        | j                  dt        j                         d | _        y )NrZ   )	superr   default_capabilitiesr#   rR   r*   r	   r
   mobile_optionsr   	__class__s    r   r   zBaseOptions.__init__l  sB    ..
.0@0G0GH"r   c                     | j                   S r   r#   r   s    r   capabilitieszBaseOptions.capabilitiess  s    zzr   c                 "    || j                   |<   y)zSets a capability.Nrf   )r   r   r,   s      r   r*   zBaseOptions.set_capabilityw  s     

4r   android_packageandroid_activitydevice_serialc                 v    |st        d      d|i| _        |r|| j                  d<   |r|| j                  d<   yy)zEnables mobile browser use for browsers that support it.

        :Args:
            android_activity: The name of the android package to start
        z!android_package must be passed inandroidPackageandroidActivityandroidDeviceSerialN)AttributeErrorrb   )r   rj   rk   rl   s       r   enable_mobilezBaseOptions.enable_mobile{  sM      !DEE/A5ED 129FD 56 r   c                      y)z-Convert options into capabilities dictionary.Nr   rg   s    r   rU   zBaseOptions.to_capabilities      r   c                      y)z6Return minimal capabilities necessary as a dictionary.Nr   rg   s    r   ra   z BaseOptions.default_capabilities  rt   r   r^   N)NNN)r   r   r   r   r   browser_versionplatform_nameaccept_insecure_certsstrict_file_interactabilityset_window_rectr/   page_load_strategyr9   unhandled_prompt_behaviorrA   r\   rO   r]   enable_downloadsr   propertyrh   r*   typingOptionalstrrr   r   rU   ra   __classcell__rd   s   @r   rW   rW      s`   4,-=>O* +>:M* 33HI* #99T"U* -_=O* 55GH* !CC\ ], #:.H, W%E* ..CD*#  ! 1515.2	G-G !//#.G s+	G
 
G& < < E  Er   rW   )	metaclassc                   Z     e Zd ZdZd fdZed        ZddZddZd Z	ed        Z
 xZS )	
ArgOptionsz Binary Location Must be a Stringc                 >    t         |           g | _        d| _        y )NF)r`   r   
_arguments_ignore_local_proxyrc   s    r   r   zArgOptions.__init__  s    #( r   c                     | j                   S )z5:Returns: A list of arguments needed for the browser.)r   rg   s    r   	argumentszArgOptions.arguments  s     r   c                 T    |r| j                   j                  |       yt        d      )zTAdds an argument to the list.

        :Args:
         - Sets the arguments
        zargument can not be nullN)r   appendr6   )r   arguments     r   add_argumentzArgOptions.add_argument  s%     OO""8,788r   c                     d| _         y)zaBy calling this you will ignore HTTP_PROXY and HTTPS_PROXY from
        being picked up and used.TN)r   rg   s    r   (ignore_local_proxy_environment_variablesz3ArgOptions.ignore_local_proxy_environment_variables  s     $( r   c                     | j                   S r   rf   rg   s    r   rU   zArgOptions.to_capabilities  s    zzr   c                     i S r   r   rg   s    r   ra   zArgOptions.default_capabilities  s    	r   rv   )r   r   r   BINARY_LOCATION_ERRORr   r   r   r   r   rU   ra   r   r   s   @r   r   r     sE    >)
  	9(
  r   r   )r   abcr   r   enumr   selenium.common.exceptionsr   selenium.webdriver.common.proxyr   r   r	   r   r/   r9   rA   rO   rW   r   r   r   r   <module>r      sz   "     ? 1sD  
- 
-_ _( 4j j,7 7 JEG JEZ" "r   