o
    US`c#                     @   sV   d dl Z d dlmZ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d4 fddZedd Zd4dd	Zedefd
dZ	e	j
deddfddZ	edefddZej
deddfddZedefddZej
deddfddZedefddZej
deddfddZedefddZej
deddfddZ		d5deje deje d eje ddfd!d"Zedefd#d$Zej
d%eddfd&d$Zedefd'd(Zej
d%eddfd)d(Zedefd*d+Zej
d%eddfd,d+Zedefd-d.Zej
d%eddfd/d.Zed0d1 Zeed2d3 Z  ZS )6BaseOptionsz3
    Base class for individual browser options
    returnNc                    s(   t    | j| _| dd d | _d S )NpageLoadStrategynormal)super__init__default_capabilities_capsset_capabilitymobile_optionsself	__class__ L/usr/local/lib/python3.10/dist-packages/selenium/webdriver/common/options.pyr      s   

zBaseOptions.__init__c                 C      | 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   
   | j d S )zN
        :returns: the version of the browser if set, otherwise None.
        browserVersionr   r   r   r   r   browser_version+      
zBaseOptions.browser_versionversionc                 C      |  d| dS )z
        Requires 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   2   s   c                 C   r   )z4
        :returns: The name of the platform
        platformNamer   r   r   r   r   platform_name<   r   zBaseOptions.platform_nameplatformc                 C   r!   )z
        Requires 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$   C   s   c                 C   r   )zN
        :returns: page load strategy if set, the default is "normal"
        r   r   r   r   r   r   page_load_strategyL   r   zBaseOptions.page_load_strategystrategyc                 C       |dv r|  d| dS td)z
        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
        )r	   eagernoner   z>Strategy can only be one of the following: normal, eager, noneNr   
ValueError)r   r'   r   r   r   r&   S      c                 C   r   )za
        :returns: unhandled prompt behavior if set, the default is "dismiss and notify"
        unhandledPromptBehaviorr   r   r   r   r   unhandled_prompt_behavior`   r   z%BaseOptions.unhandled_prompt_behaviorbehaviorc                 C   r(   )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   r0   r   r   r   r/   g   r-   c                 C   r   )zu
        :returns: Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)
        timeoutsr   r   r   r   r   r3   u   r   zBaseOptions.timeoutsr3   c                    s.   t  fdddD r| d  dS td)z
        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
        c                 3   s    | ]	}|   v V  qd S r   )keys).0xr3   r   r   	<genexpr>   s    z'BaseOptions.timeouts.<locals>.<genexpr>)ZimplicitZpageLoadscriptr3   zITimeout keys can only be one of the following: implicit, pageLoad, scriptN)allr   r,   )r   r3   r   r7   r   r3   |   s   android_packageandroid_activitydevice_serialc                 C   s:   |st dd|i| _|r|| jd< |r|| jd< dS 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)AttributeErrorr   )r   r;   r<   r=   r   r   r   enable_mobile   s   
zBaseOptions.enable_mobilec                 C      | j ddS )zM
        :returns: whether the session accepts insecure certificates
        acceptInsecureCertsFr   getr   r   r   r   accept_insecure_certs      z!BaseOptions.accept_insecure_certsr   c                 C      || j d< dS )z
        Whether 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
        rA   Nr   r   r   r   r   r   rD         c                 C   r@   )zP
        :returns: whether session is strict about file interactability
        strictFileInteractabilityFrB   r   r   r   r   strict_file_interactability   rE   z'BaseOptions.strict_file_interactabilityc                 C   rF   )z
        Whether interactability checks will be applied to file type input elements. The default is false.

        :param value: whether file interactability is strict
        rI   Nr   rG   r   r   r   rJ      s   c                 C   r@   )z\
        :returns: whether the remote end supports setting window size and position
        setWindowRectFrB   r   r   r   r   set_window_rect   rE   zBaseOptions.set_window_rectc                 C   rF   )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
        rK   Nr   rG   r   r   r   rL      rH   c                 C   r   )z9
        :Returns: Proxy if set, otherwise None.
        )_proxyr   r   r   r   proxy      zBaseOptions.proxyc                 C   s   t |ts	td|| _d S )Nz$Only Proxy objects can be passed in.)
isinstancer   r   rM   rG   r   r   r   rN      s   

c                 C      dS )z-Convert options into capabilities dictionary.Nr   r   r   r   r   to_capabilities       zBaseOptions.to_capabilitiesc                 C   rQ   )z6Return minimal capabilities necessary as a dictionary.Nr   r   r   r   r   r      rS   z BaseOptions.default_capabilitiesr   N)NNN)__name__
__module____qualname____doc__r   propertyr   r   strr   setterr$   r&   r/   dictr3   typingOptionalr?   boolrD   rJ   rL   r   rN   r   rR   r   __classcell__r   r   r   r   r      sl    

	
		
r   )	metaclassc                       sP   e Zd Zd fddZedd Zdd Zdd	d
Zdd Zedd Z	  Z
S )
ArgOptionsr   Nc                    s   t    g | _d| _d S )NF)r
   r   
_arguments_ignore_local_proxyr   r   r   r   r      s   

zArgOptions.__init__c                 C   r   )zF
        :Returns: A list of arguments needed for the browser
        )rc   r   r   r   r   	arguments   rO   zArgOptions.argumentsc                 C   s   |r
| j | dS td)z\
        Adds an argument to the list

        :Args:
         - Sets the arguments
        zargument can not be nullN)rc   appendr,   )r   argumentr   r   r   add_argument   s   zArgOptions.add_argumentc                 C   s
   d| _ dS )zo
            By calling this you will ignore HTTP_PROXY and HTTPS_PROXY from being picked up and used.
        TN)rd   r   r   r   r   (ignore_local_proxy_environment_variables   s   
z3ArgOptions.ignore_local_proxy_environment_variablesc                 C   r   r   r   r   r   r   r   rR     s   zArgOptions.to_capabilitiesc                 C   s   i S r   r   r   r   r   r   r     s   zArgOptions.default_capabilitiesrT   )rU   rV   rW   r   rY   re   rh   ri   rR   r   r`   r   r   r   r   rb      s    

rb   )
r]   abcr   r   Zselenium.common.exceptionsr   Zselenium.webdriver.common.proxyr   r   rb   r   r   r   r   <module>   s    M