a
    xd#                     @   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 G dd dedZG d	d
 d
eZ	dS )    N)ABCMeta)abstractmethod)InvalidArgumentException)Proxyc                       s  e Zd ZdZdd fddZedd Zdddd	Zeedd
dZ	e	j
eddddZ	eedddZej
eddddZeedddZej
eddddZeedddZej
eddddZeedddZej
eddddZd2eje eje eje dddd Zeedd!d"Zej
edd#d$d"Zeedd%d&Zej
edd#d'd&Zeedd(d)Zej
edd#d*d)Zeedd+d,Zej
edd#d-d,Zed.d/ Zeed0d1 Z  ZS )3BaseOptionsz*Base class for individual browser options.Nreturnc                    s(   t    | j| _| dd d | _d S )NpageLoadStrategynormal)super__init__default_capabilities_capsset_capabilitymobile_optionsself	__class__ Y/var/www/html/Ranjet/env/lib/python3.9/site-packages/selenium/webdriver/common/options.pyr      s    
zBaseOptions.__init__c                 C   s   | j S Nr   r   r   r   r   capabilities"   s    zBaseOptions.capabilitiesc                 C   s   || j |< dS )zSets a capability.Nr   )r   namevaluer   r   r   r   &   s    zBaseOptions.set_capabilityc                 C   s   | j dS )zN
        :returns: the version of the browser if set, otherwise None.
        browserVersionr   getr   r   r   r   browser_version*   s    zBaseOptions.browser_version)versionr   c                 C   s   |  d| dS )zRequires the major version of the browser to match provided value:
        https://w3c.github.io/webdriver/#dfn-browser-version.

        :param version: The required version of the browser
        r   Nr   )r   r    r   r   r   r   1   s    c                 C   s
   | j d S )z4
        :returns: The name of the platform
        platformNamer   r   r   r   r   platform_name:   s    zBaseOptions.platform_name)platformr   c                 C   s   |  d| dS )zRequires the platform to match the provided value:
        https://w3c.github.io/webdriver/#dfn-platform-name.

        :param platform: the required name of the platform
        r"   Nr!   )r   r$   r   r   r   r#   A   s    c                 C   s
   | j d S )zN
        :returns: page load strategy if set, the default is "normal"
        r	   r   r   r   r   r   page_load_strategyJ   s    zBaseOptions.page_load_strategy)strategyr   c                 C   s"   |dv r|  d| ntddS )zDetermines 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
        )r
   eagernoner	   z>Strategy can only be one of the following: normal, eager, noneNr   
ValueError)r   r&   r   r   r   r%   Q   s    c                 C   s
   | j d S )za
        :returns: unhandled prompt behavior if set, the default is "dismiss and notify"
        unhandledPromptBehaviorr   r   r   r   r   unhandled_prompt_behavior]   s    z%BaseOptions.unhandled_prompt_behavior)behaviorr   c                 C   s"   |dv r|  d| ntddS )a
  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
        )Zdismissacceptzdismiss and notifyzaccept and notifyignorer+   ziBehavior can only be one of the following: dismiss, accept, dismiss and notify, accept and notify, ignoreNr)   )r   r-   r   r   r   r,   d   s
    c                 C   s
   | j d S )zu
        :returns: Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)
        timeoutsr   r   r   r   r   r0   t   s    zBaseOptions.timeouts)r0   r   c                 C   s0   t dd | D r$| d| ntddS )zHow 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
        c                 s   s   | ]}|d v V  qdS ))ZimplicitZpageLoadscriptNr   ).0xr   r   r   	<genexpr>       z'BaseOptions.timeouts.<locals>.<genexpr>r0   zITimeout keys can only be one of the following: implicit, pageLoad, scriptN)allkeysr   r*   )r   r0   r   r   r   r0   {   s    )android_packageandroid_activitydevice_serialr   c                 C   s6   |st dd|i| _|r$|| jd< |r2|| jd< 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 inZandroidPackageZandroidActivityZandroidDeviceSerialN)AttributeErrorr   )r   r8   r9   r:   r   r   r   enable_mobile   s    

zBaseOptions.enable_mobilec                 C   s   | j ddS )zM
        :returns: whether the session accepts insecure certificates
        acceptInsecureCertsFr   r   r   r   r   accept_insecure_certs   s    z!BaseOptions.accept_insecure_certs)r   r   c                 C   s   || j d< dS )zWhether untrusted and self-signed TLS certificates are implicitly
        trusted: https://w3c.github.io/webdriver/#dfn-insecure-tls-
        certificates.

        :param value: whether to accept insecure certificates
        r=   Nr   r   r   r   r   r   r>      s    c                 C   s   | j ddS )zP
        :returns: whether session is strict about file interactability
        strictFileInteractabilityFr   r   r   r   r   strict_file_interactability   s    z'BaseOptions.strict_file_interactabilityc                 C   s   || j d< dS )zWhether interactability checks will be applied to file type input
        elements. The default is false.

        :param value: whether file interactability is strict
        r@   Nr   r?   r   r   r   rA      s    c                 C   s   | j ddS )z\
        :returns: whether the remote end supports setting window size and position
        setWindowRectFr   r   r   r   r   set_window_rect   s    zBaseOptions.set_window_rectc                 C   s   || j d< dS )a   Whether the remote end supports all of the resizing and positioning
        commands. The default is false. https://w3c.github.io/webdriver/#dfn-
        strict-file-interactability.

        :param value: whether remote end must support setting window resizing and repositioning
        rB   Nr   r?   r   r   r   rC      s    c                 C   s   | j S )z9
        :Returns: Proxy if set, otherwise None.
        )_proxyr   r   r   r   proxy   s    zBaseOptions.proxyc                 C   s   t |tstd|| _d S )Nz$Only Proxy objects can be passed in.)
isinstancer   r   rD   r?   r   r   r   rE      s    
c                 C   s   dS )z-Convert options into capabilities dictionary.Nr   r   r   r   r   to_capabilities   s    zBaseOptions.to_capabilitiesc                 C   s   dS )z6Return minimal capabilities necessary as a dictionary.Nr   r   r   r   r   r      s    z BaseOptions.default_capabilities)NNN)__name__
__module____qualname____doc__r   propertyr   r   strr   setterr#   r%   r,   dictr0   typingOptionalr<   boolr>   rA   rC   r   rE   r   rG   r   __classcell__r   r   r   r   r      sn   
   		
r   )	metaclassc                       sX   e Zd Zdd fddZedd Zdd Zddd	d
Zdd Zedd Z	  Z
S )
ArgOptionsNr   c                    s   t    g | _d| _d S )NF)r   r   
_arguments_ignore_local_proxyr   r   r   r   r      s    
zArgOptions.__init__c                 C   s   | j S )zF
        :Returns: A list of arguments needed for the browser
        )rV   r   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)rV   appendr*   )r   argumentr   r   r   add_argument   s    zArgOptions.add_argumentc                 C   s
   d| _ dS )zaBy calling this you will ignore HTTP_PROXY and HTTPS_PROXY from
        being picked up and used.TN)rW   r   r   r   r   (ignore_local_proxy_environment_variables   s    z3ArgOptions.ignore_local_proxy_environment_variablesc                 C   s   | j S r   r   r   r   r   r   rG      s    zArgOptions.to_capabilitiesc                 C   s   i S r   r   r   r   r   r   r     s    zArgOptions.default_capabilities)rH   rI   rJ   r   rL   rX   r[   r\   rG   r   rS   r   r   r   r   rU      s   
rU   )
rP   abcr   r   Zselenium.common.exceptionsr   Zselenium.webdriver.common.proxyr   r   rU   r   r   r   r   <module>   s    K