
     f2                     $   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dS )    N)ABCMeta)abstractmethod)Enum)InvalidArgumentException)Proxyc                       e Zd ZdZdZdZdZdS )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        d/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/selenium/webdriver/common/options.pyr	   r	      s)          FEDDDr   r	   c                        e Zd Zd Zd Zd ZdS )_BaseOptionsDescriptorc                     || _         d S Nnameselfr   s     r   __init__z_BaseOptionsDescriptor.__init__+       			r   c                    | j         dk    r3|j                            d          }|du pt          |t                    S | j         dk    r8|j                            | j                   }t          |t                    sd n|S | j         dv r |j                            | j         d          S |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    9$$IMM.11ED=:Juc$:$::9&&IMM$),,E)%55@445@9ttt9==E222y}}TY'''r   c                     | j         dk    r|                    d|           d S |                    | j         |           d S )Nr   r    )r   set_capabilityr   r)   r+   s      r   __set__z_BaseOptionsDescriptor.__set__;   sI    9$$~u55555ty%00000r   N)r   r   r   r   r,   r0   r   r   r   r   r   *   sA          ( ( (1 1 1 1 1r   r   c                   $    e Zd ZdZd Zd Zd ZdS )_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                     || _         d S r   r   r   s     r   r   z$_PageLoadStrategyDescriptor.__init__I   r   r   c                 @    |j                             | j                  S r   r%   r&   r   r   r)   r*   s      r   r,   z#_PageLoadStrategyDescriptor.__get__L       y}}TY'''r   c                 b    |dv r|                     | j        |           d S 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__O   s;    ///ty%00000]^^^r   Nr   r   r   r   r   r,   r0   r   r   r   r2   r2   B   sP           ( ( (_ _ _ _ _r   r2   c                   $    e Zd ZdZd Zd Zd ZdS )"_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                     || _         d S r   r   r   s     r   r   z+_UnHandledPromptBehaviorDescriptor.__init__`   r   r   c                 @    |j                             | j                  S r   r5   r6   s      r   r,   z*_UnHandledPromptBehaviorDescriptor.__get__c   r7   r   c                 b    |dv r|                     | j        |           d S 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__f   sC    ^^^ty%00000,  r   Nr;   r   r   r   r=   r=   V   sK           ( ( (    r   r=   c                   $    e Zd ZdZd Zd Zd ZdS )_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                     || _         d S r   r   r   s     r   r   z_TimeoutsDescriptor.__init__y   r   r   c                 @    |j                             | j                  S r   r5   r6   s      r   r,   z_TimeoutsDescriptor.__get__|   r7   r   c                     t          d |                                D                       r|                    | j        |           d S t	          d          )Nc              3      K   | ]}|d v V  	dS ))implicitpageLoadscriptNr   ).0xs     r   	<genexpr>z._TimeoutsDescriptor.__set__.<locals>.<genexpr>   s(      MM1q66MMMMMMr   zITimeout keys can only be one of the following: implicit, pageLoad, script)allkeysr.   r   r:   r/   s      r   r0   z_TimeoutsDescriptor.__set__   sW    MM

MMMMM 	jty%00000hiiir   Nr;   r   r   r   rE   rE   p   sP           ( ( (j j j j jr   rE   c                   $    e Zd ZdZd Zd Zd ZdS )_ProxyDescriptorz':Returns: Proxy if set, otherwise None.c                     || _         d S r   r   r   s     r   r   z_ProxyDescriptor.__init__   r   r   c                     |j         S r   )_proxyr6   s      r   r,   z_ProxyDescriptor.__get__   s
    zr   c                     t          |t                    st          d          ||_        |                                |j        | j        <   d S )Nz$Only Proxy objects can be passed in.)r'   r   r   rV   to_capabilitiesr%   r   r/   s      r   r0   z_ProxyDescriptor.__set__   sK    %'' 	S*+QRRR
$4466	$)r   Nr;   r   r   r   rS   rS      sG        11    7 7 7 7 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j        e         dej        e         dej        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 | _        |                     dt          j                   d | _        d| _	        d S )Nr]   F)
superr   default_capabilitiesr%   rV   r.   r	   r
   mobile_options_ignore_local_proxyr   	__class__s    r   r   zBaseOptions.__init__  s[    .
.0@0GHHH"#(   r   c                     | j         S r   r%   r   s    r   capabilitieszBaseOptions.capabilities  s
    zr   c                     || j         |<   dS )zSets a capability.Nrj   )r   r   r+   s      r   r.   zBaseOptions.set_capability  s     
4r   android_packageandroid_activitydevice_serialc                 n    |st          d          d|i| _        |r
|| j        d<   |r|| j        d<   dS dS )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  si      	F !DEEE/A 	F5ED 12 	G9FD 5666	G 	Gr   c                     dS )z-Convert options into capabilities dictionary.Nr   rk   s    r   rX   zBaseOptions.to_capabilities        r   c                     dS )z6Return minimal capabilities necessary as a dictionary.Nr   rk   s    r   rd   z BaseOptions.default_capabilities  rx   r   c                     d| _         dS )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      sf       44,,-=>>O* +*>::M* 323HII* #9"89T"U"U* -,_==O* )(66K* ,+N;;N* 545GHH* !C BC\ ] ], #":..H, W%%E* .-.CDD* ,+N;;N*) ) ) ) ) )   X! ! ! ! 1515.2	G G-G !/#.G s+	G
 
G G G G& < < ^< E E ^ XE( ( ( ( ( ( ( (r   rZ   )	metaclassc                   j     e 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 Stringra   Nc                 V    t                                                       g | _        d S 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                 \    |r| j                             |           dS 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  s7      	9O""8,,,,,7888r   c                 H    t                                                       dS )r{   N)rc   r|   rg   s    r   r|   z3ArgOptions.ignore_local_proxy_environment_variables  s!     	88:::::r   c                     | j         S r   rj   rk   s    r   rX   zArgOptions.to_capabilities  s
    zr   c                     i S r   r   rk   s    r   rd   zArgOptions.default_capabilities
  s    	r   r}   )r   r   r   BINARY_LOCATION_ERRORr   r   r   r   r|   rX   rd   r   r   s   @r   r   r     s        >        X	9 	9 	9 	9; ; ; ; ; ;
     X    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 1 1 1 1 1    sD    1 1 1 1 1 1 1 10_ _ _ _ _ _ _ _(       4j j j j j j j j,7 7 7 7 7 7 7 7 R( R( R( R( R(G R( R( R( R(j
! ! ! ! ! ! ! ! ! !r   