
    g4                         d dl Z 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        T/var/www/html/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k(  r1|j                  j                  d      }|du xs t        |t              S | j                   dk(  r9|j                  j                  | j                         }t        |t              sd S |S | j                   dv r&|j                  j                  | j                   d      S |j                  j                  | j                         S )N
enableBidiwebSocketUrlT)acceptInsecureCertsstrictFileInteractabilitysetWindowRectse:downloadsEnabledF)r   _capsget
isinstancestr)r   objclsvalues       r   __get__z_BaseOptionsDescriptor.__get__/   s    99$IIMM.1ED=:Juc$::99&IIMM$)),E)%54@5@99tt99==E22yy}}TYY''r   c                     | j                   dk(  r|j                  d|       y |j                  | j                   |       y )Nr   r    )r   set_capabilityr   r)   r+   s      r   __set__z_BaseOptionsDescriptor.__set__<   s2    99$~u5tyy%0r   N)r   r   r   r   r,   r0   r   r   r   r   r   +   s    (1r   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__J   r   r   c                 L    |j                   j                  | j                        S r   r%   r&   r   r   r)   r*   s      r   r,   z#_PageLoadStrategyDescriptor.__get__M       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   r0   z#_PageLoadStrategyDescriptor.__set__P   s+    //tyy%0]^^r   Nr   r   r   r   r   r,   r0   r   r   r   r2   r2   C   s    (_r   r2   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__a   r   r   c                 L    |j                   j                  | j                        S r   r5   r6   s      r   r,   z*_UnHandledPromptBehaviorDescriptor.__get__d   r7   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, ignorer9   r/   s      r   r0   z*_UnHandledPromptBehaviorDescriptor.__set__g   s1    ^^tyy%0, r   Nr;   r   r   r   r=   r=   W   s    (r   r=   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__z   r   r   c                 L    |j                   j                  | j                        S r   r5   r6   s      r   r,   z_TimeoutsDescriptor.__get__}   r7   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>   s     M1q66Ms   zITimeout keys can only be one of the following: implicit, pageLoad, script)allkeysr.   r   r:   r/   s      r   r0   z_TimeoutsDescriptor.__set__   s6    M

MMtyy%0hiir   Nr;   r   r   r   rE   rE   q   s    (jr   rE   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   )_proxyr6   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.)r'   r   r   rV   to_capabilitiesr%   r   r/   s      r   r0   z_ProxyDescriptor.__set__   s:    %'*+QRR
$446		$))r   Nr;   r   r   r   rS   rS      s    17r   rS   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	  ed      Z	  ed      Z	  ed      Z	 d fdZed        ZddZ	 	 	 ddej4                  e   dej4                  e   dej4                  e   ddfdZed        Zeed               ZddZ  xZ!S )BaseOptionsz*Base class for individual browser options.browserVersionplatformNamer!   r"   r#   r   r    pageLoadStrategyunhandledPromptBehaviortimeoutsproxyr$   returnNc                     t         |           | j                  | _        d | _        | j                  dt        j                         d | _        d| _	        y )Nr]   F)
superr   default_capabilitiesr%   rV   r.   r	   r
   mobile_options_ignore_local_proxyr   	__class__s    r   r   zBaseOptions.__init__  sJ    ..
.0@0G0GH"#( r   c                     | j                   S r   r%   r   s    r   capabilitieszBaseOptions.capabilities  s    zzr   c                 "    || j                   |<   y)zSets a capability.Nrj   )r   r   r+   s      r   r.   zBaseOptions.set_capability  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)AttributeErrorre   )r   rn   ro   rp   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   rk   s    r   rX   zBaseOptions.to_capabilities      r   c                      y)z6Return minimal capabilities necessary as a dictionary.Nr   rk   s    r   rd   z BaseOptions.default_capabilities  rx   r   c                     d| _         y)aBy calling this you will ignore HTTP_PROXY and HTTPS_PROXY from
        being picked up and used.TN)rf   rk   s    r   (ignore_local_proxy_environment_variablesz4BaseOptions.ignore_local_proxy_environment_variables  s     $( r   ra   N)NNN)"r   r   r   r   r   browser_versionplatform_nameaccept_insecure_certsstrict_file_interactabilityset_window_rectenable_bidiweb_socket_urlr2   page_load_strategyr=   unhandled_prompt_behaviorrE   r_   rS   r`   enable_downloadsr   propertyrl   r.   typingOptionalr(   rv   r   rX   rd   r|   __classcell__rh   s   @r   rZ   rZ      s   4,-=>O* +>:M* 33HI* #99T"U* -_=O* )6K* ,N;N* 55GH* !CC\ ], #:.H, W%E* ..CD* ,N;N*)  ! 1515.2	G-G !//#.G s+	G
 
G& < < E  E(r   rZ   )	metaclassc                   b     e Zd ZdZdZd	 fdZed        Zd	dZd	 fdZ	d Z
ed        Z xZS )

ArgOptionsz Binary Location Must be a Stringzfedcm:accountsc                 0    t         |           g | _        y r   )rc   r   
_argumentsrg   s    r   r   zArgOptions.__init__  s    r   c                     | j                   S )z5:Returns: A list of arguments needed for the browser.)r   rk   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   appendr:   )r   arguments     r   add_argumentzArgOptions.add_argument  s%     OO""8,788r   c                 Z    t        j                  dt        d       t        |           y)r{   a  using ignore_local_proxy_environment_variables in Options has been deprecated, instead, create a Proxy instance with ProxyType.DIRECT to ignore proxy settings, pass the proxy instance into a ClientConfig constructor, pass the client config instance into the Webdriver constructor   )
stacklevelN)warningswarnDeprecationWarningrc   r|   rg   s    r   r|   z3ArgOptions.ignore_local_proxy_environment_variables  s,     	M 	
 	8:r   c                     | j                   S r   rj   rk   s    r   rX   zArgOptions.to_capabilities  s    zzr   c                     i S r   r   rk   s    r   rd   zArgOptions.default_capabilities  s    	r   r}   )r   r   r   BINARY_LOCATION_ERRORFEDCM_CAPABILITYr   r   r   r   r|   rX   rd   r   r   s   @r   r   r     sK    >'  	9;  r   r   )r   r   abcr   r   enumr   selenium.common.exceptionsr   selenium.webdriver.common.proxyr   r(   r	   r   r2   r=   rE   rS   rZ   r   r   r   r   <module>r      s{   "      ? 1sD  1 10_ _( 4j j,7 7 R(G R(j
, ,r   