
    A\hE3                         d dl Z d dlmZmZ d dlmZ d dlmZ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)ListOptional)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/trade_iq/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.   r2   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r0   r   
ValueErrorr1   s      r   r2   z#_PageLoadStrategyDescriptor.__set__P   s+    //tyy%0]^^r   Nr   r   r   r   r   r.   r2   r   r   r   r4   r4   C   s    (_r   r4   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   r7   r8   s      r   r.   z*_UnHandledPromptBehaviorDescriptor.__get__d   r9   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, ignorer;   r1   s      r   r2   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   r7   r8   s      r   r.   z_TimeoutsDescriptor.__get__}   r9   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keysr0   r   r<   r1   s      r   r2   z_TimeoutsDescriptor.__set__   s6    M

MMtyy%0hiir   Nr=   r   r   r   rG   rG   q   s    (jr   rG   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   )_proxyr8   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   rX   to_capabilitiesr'   r   r1   s      r   r2   z_ProxyDescriptor.__set__   s:    %'*+QRR
$446		$))r   Nr=   r   r   r   rU   rU      s    17r   rU   c            	       x    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	 d fdZed        ZddZ	 	 	 ddee   dee   de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!   pageLoadStrategyunhandledPromptBehaviortimeoutsproxyr&   r"   returnNc                     t         |           | j                  | _        d | _        | j                  dt        j                         d | _        d| _	        y )Nr_   F)
superr   default_capabilitiesr'   rX   r0   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.Nrl   )r   r   r-   s      r   r0   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)AttributeErrorrg   )r   rp   rq   rr   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   rm   s    r   rZ   zBaseOptions.to_capabilities      r   c                      y)z6Return minimal capabilities necessary as a dictionary.Nr   rm   s    r   rf   z BaseOptions.default_capabilities  rz   r   c                     d| _         y)aBy calling this you will ignore HTTP_PROXY and HTTPS_PROXY from
        being picked up and used.TN)rh   rm   s    r   (ignore_local_proxy_environment_variablesz4BaseOptions.ignore_local_proxy_environment_variables  s     $( r   rc   N)NNN)!r   r   r   r   r   browser_versionplatform_nameaccept_insecure_certsstrict_file_interactabilityset_window_rectenable_bidir4   page_load_strategyr?   unhandled_prompt_behaviorrG   ra   rU   rb   enable_downloadsweb_socket_urlr   propertyrn   r0   r   r*   rx   r   rZ   rf   r~   __classcell__rj   s   @r   r\   r\      sx   4,-=>O* +>:M* 33HI* #99T"U* -_=O* )6K* 55GH* !CC\ ], #:.H, W%E* ..CD* ,N;N*)  ! *.*.'+	G!#G #3-G  }	G
 
G& < < E  E(r   r\   )	metaclassc                   j     e Zd ZdZdZd fdZed        ZdeddfdZ	d fd	Z
d
 Zed        Z xZS )
ArgOptionsz Binary Location Must be a Stringzfedcm:accountsrc   Nc                 0    t         |           g | _        y r   )re   r   
_argumentsri   s    r   r   zArgOptions.__init__  s    %'r   c                     | j                   S )z5:Returns: A list of arguments needed for the browser.)r   rm   s    r   	argumentszArgOptions.arguments  s     r   argumentc                 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   r   s     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DeprecationWarningre   r~   ri   s    r   r~   z3ArgOptions.ignore_local_proxy_environment_variables  s,     	M 	
 	8:r   c                     | j                   S r   rl   rm   s    r   rZ   zArgOptions.to_capabilities  s    zzr   c                     i S r   r   rm   s    r   rf   zArgOptions.default_capabilities   s    	r   r   )r   r   r   BINARY_LOCATION_ERRORFEDCM_CAPABILITYr   r   r   r*   r   r~   rZ   rf   r   r   s   @r   r   r     sY    >'(  	9S 	9T 	9;  r   r   )r   abcr   r   enumr   typingr   r   selenium.common.exceptionsr   selenium.webdriver.common.proxyr	   r*   r   r   r4   r?   rG   rU   r\   r   r   r   r   <module>r      sx   $  '  ! ? 1sD  1 10_ _( 4j j,7 7 |(G |(~	, ,r   