a
    5ñ»j>3  ã                   @   sÎ   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 G dd	„ d	eeƒZG d
d„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZG dd„ ded�ZG dd„ deƒZdS )é    N)ÚABCMeta)Úabstractmethod)ÚEnum)ÚOptional)ÚInvalidArgumentException)ÚProxyc                   @   s   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   © r   r   úGE:\soccer\ml_env\Lib\site-packages\selenium/webdriver/common/options.pyr      s   
r   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )Ú_BaseOptionsDescriptorc                 C   s
   || _ d S ©N©Úname©Úselfr   r   r   r   Ú__init__-   s    z_BaseOptionsDescriptor.__init__c                 C   sz   | j dkr(|j d¡}|du p&t|tƒS | j dkrR|j | j ¡}t|tƒsNd S |S | j dv rl|j | j d¡S |j | j ¡S )NÚ
enableBidiÚwebSocketUrlT)ÚacceptInsecureCertsÚstrictFileInteractabilityÚsetWindowRectúse:downloadsEnabledF)r   Ú_capsÚgetÚ
isinstanceÚstr)r   ÚobjÚclsÚvaluer   r   r   Ú__get__0   s    


z_BaseOptionsDescriptor.__get__c                 C   s*   | j dkr| d|¡ n| | j |¡ d S )Nr   r   )r   Úset_capability©r   r#   r%   r   r   r   Ú__set__=   s    
z_BaseOptionsDescriptor.__set__N)r   r   r   r   r&   r)   r   r   r   r   r   ,   s   r   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú_PageLoadStrategyDescriptorzÛDetermines 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                 C   s
   || _ d S r   r   r   r   r   r   r   K   s    z$_PageLoadStrategyDescriptor.__init__c                 C   s   |j  | j¡S r   ©r   r    r   ©r   r#   r$   r   r   r   r&   N   s    z#_PageLoadStrategyDescriptor.__get__c                 C   s$   |dv r|  | j|¡ ntdƒ‚d S )N)r	   r
   r   z>Strategy can only be one of the following: normal, eager, none©r'   r   Ú
ValueErrorr(   r   r   r   r)   Q   s    z#_PageLoadStrategyDescriptor.__set__N©r   r   r   r   r   r&   r)   r   r   r   r   r*   D   s   r*   c                   @   s(   e Zd ZdZdd„ Zdd„ Zd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                 C   s
   || _ d S r   r   r   r   r   r   r   b   s    z+_UnHandledPromptBehaviorDescriptor.__init__c                 C   s   |j  | j¡S r   r+   r,   r   r   r   r&   e   s    z*_UnHandledPromptBehaviorDescriptor.__get__c                 C   s$   |dv r|  | j|¡ ntdƒ‚d S )N)Z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-   r(   r   r   r   r)   h   s
    ÿz*_UnHandledPromptBehaviorDescriptor.__set__Nr/   r   r   r   r   r0   X   s   	r0   c                   @   s(   e Zd ZdZdd„ Zdd„ Zd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                 C   s
   || _ d S r   r   r   r   r   r   r   {   s    z_TimeoutsDescriptor.__init__c                 C   s   |j  | j¡S r   r+   r,   r   r   r   r&   ~   s    z_TimeoutsDescriptor.__get__c                 C   s2   t dd„ | ¡ D ƒƒr&| | j|¡ ntdƒ‚d S )Nc                 s   s   | ]}|d v V  qdS ))ZimplicitZpageLoadÚscriptNr   )Ú.0Úxr   r   r   Ú	<genexpr>‚   ó    z._TimeoutsDescriptor.__set__.<locals>.<genexpr>zITimeout keys can only be one of the following: implicit, pageLoad, script)ÚallÚkeysr'   r   r.   r(   r   r   r   r)   �   s    z_TimeoutsDescriptor.__set__Nr/   r   r   r   r   r3   r   s   r3   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú_ProxyDescriptorz':Returns: Proxy if set, otherwise None.c                 C   s
   || _ d S r   r   r   r   r   r   r   ‹   s    z_ProxyDescriptor.__init__c                 C   s   |j S r   )Ú_proxyr,   r   r   r   r&   Ž   s    z_ProxyDescriptor.__get__c                 C   s,   t |tƒstdƒ‚||_| ¡ |j| j< d S )Nz$Only Proxy objects can be passed in.)r!   r   r   r<   Úto_capabilitiesr   r   r(   r   r   r   r)   ‘   s    
z_ProxyDescriptor.__set__Nr/   r   r   r   r   r;   ˆ   s   r;   c                       sì   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dœ‡ fdd„Zedd„ ƒZddœdd„Zdee ee ee ddœdd„Zedd„ ƒZeedd„ ƒƒZddœdd„Z‡  Z S ) ÚBaseOptionsz*Base class for individual browser options.ZbrowserVersionZplatformNamer   r   r   r   ÚpageLoadStrategyZunhandledPromptBehaviorÚtimeoutsÚproxyr   r   N©Úreturnc                    s6   t ƒ  ¡  | j| _d | _|  dtj¡ d | _d| _	d S )Nr?   F)
Úsuperr   Údefault_capabilitiesr   r<   r'   r   r	   Úmobile_optionsÚ_ignore_local_proxy©r   ©Ú	__class__r   r   r   ¥  s    
zBaseOptions.__init__c                 C   s   | j S r   ©r   rH   r   r   r   Úcapabilities­  s    zBaseOptions.capabilitiesc                 C   s   || j |< dS )zSets a capability.NrK   )r   r   r%   r   r   r   r'   ±  s    zBaseOptions.set_capability)Úandroid_packageÚandroid_activityÚdevice_serialrC   c                 C   s6   |st dƒ‚d|i| _|r$|| jd< |r2|| jd< dS )z˜Enables 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 inZandroidPackageZandroidActivityZandroidDeviceSerialN)ÚAttributeErrorrF   )r   rM   rN   rO   r   r   r   Úenable_mobileµ  s    

zBaseOptions.enable_mobilec                 C   s   dS )z-Convert options into capabilities dictionary.Nr   rH   r   r   r   r=   È  s    zBaseOptions.to_capabilitiesc                 C   s   dS )z6Return minimal capabilities necessary as a dictionary.Nr   rH   r   r   r   rE   Ì  s    z BaseOptions.default_capabilitiesc                 C   s
   d| _ dS )úaBy calling this you will ignore HTTP_PROXY and HTTPS_PROXY from
        being picked up and used.TN)rG   rH   r   r   r   Ú(ignore_local_proxy_environment_variablesÑ  s    z4BaseOptions.ignore_local_proxy_environment_variables)NNN)!r   r   r   r   r   Zbrowser_versionZplatform_nameZaccept_insecure_certsZstrict_file_interactabilityZset_window_rectZenable_bidir*   Zpage_load_strategyr0   Zunhandled_prompt_behaviorr3   r@   r;   rA   Zenable_downloadsZweb_socket_urlr   ÚpropertyrL   r'   r   r"   rQ   r   r=   rE   rS   Ú__classcell__r   r   rI   r   r>   ˜   s@   
   üû
r>   )Ú	metaclassc                       sj   e Zd ZdZdZddœ‡ fdd„Zedd„ ƒZddœd	d
„Zddœ‡ fdd„Z	dd„ Z
edd„ ƒZ‡  ZS )Ú
ArgOptionsz Binary Location Must be a Stringzfedcm:accountsNrB   c                    s   t ƒ  ¡  g | _d S r   )rD   r   Ú
_argumentsrH   rI   r   r   r   Ü  s    
zArgOptions.__init__c                 C   s   | j S )z5:Returns: A list of arguments needed for the browser.)rX   rH   r   r   r   Ú	argumentsà  s    zArgOptions.argumentsc                 C   s   |r| j  |¡ ntdƒ‚dS )zTAdds an argument to the list.

        :Args:
         - Sets the arguments
        zargument can not be nullN)rX   Úappendr.   )r   Zargumentr   r   r   Úadd_argumentå  s    zArgOptions.add_argumentc                    s   t jdtdd� tƒ  ¡  dS )rR   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ÚDeprecationWarningrD   rS   rH   rI   r   r   rS   ð  s    ú	z3ArgOptions.ignore_local_proxy_environment_variablesc                 C   s   | j S r   rK   rH   r   r   r   r=   þ  s    zArgOptions.to_capabilitiesc                 C   s   i S r   r   rH   r   r   r   rE     s    zArgOptions.default_capabilities)r   r   r   ZBINARY_LOCATION_ERRORZFEDCM_CAPABILITYr   rT   rY   r[   rS   r=   rE   rU   r   r   rI   r   rW   ×  s   
rW   )r^   Úabcr   r   Úenumr   Útypingr   Zselenium.common.exceptionsr   Zselenium.webdriver.common.proxyr   r"   r   r   r*   r0   r3   r;   r>   rW   r   r   r   r   Ú<module>   s      A