U
    PÖýf  ã                   @   sŽ   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 d dl	m
Z
 d dlmZ d d	lmZ G d
d„ dƒZG dd„ de
ƒZdS )é    )ÚAny)ÚDict)ÚOptional)ÚUnion)Ú
deprecated)ÚDesiredCapabilities)Ú
ArgOptions)ÚFirefoxBinary)ÚFirefoxProfilec                   @   s(   e Zd Zddœdd„Zedœdd„ZdS )ÚLogN©Úreturnc                 C   s
   d | _ d S ©N©Úlevel©Úself© r   úF/tmp/pip-unpacked-wheel-ds5t_0qj/selenium/webdriver/firefox/options.pyÚ__init__   s    zLog.__init__c                 C   s   | j rdd| j iiS i S )NÚlogr   r   r   r   r   r   Úto_capabilities"   s    zLog.to_capabilities)Ú__name__Ú
__module__Ú__qualname__r   Údictr   r   r   r   r   r      s   r   c                       s&  e Zd ZdZddœ‡ fdd„Zeedƒedœdd„ƒƒZej	edƒe
eef 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e
eeef dœdd„Zeee dœdd„ƒZej	e
eef ddœdd„ƒZd ee dœ‡ fdd„Zedœdd„Zeedœdd„ƒZ‡  ZS )!ÚOptionszmoz:firefoxOptionsNr   c                    s2   t ƒ  ¡  d| _i | _d| jd< d | _tƒ | _d S )NÚ é   zremote.active-protocols)Úsuperr   Ú_binary_locationÚ_preferencesÚ_profiler   r   r   ©Ú	__class__r   r   r   +   s    

zOptions.__init__zuse binary_location insteadc                 C   s
   t | jƒS )z#Returns the FirefoxBinary instance.)r	   r    r   r   r   r   Úbinary5   s    zOptions.binary)Ú
new_binaryr   c                 C   s   t |tƒr|j}t|ƒ| _dS )z\Sets location of the browser binary, either by string or
        ``FirefoxBinary`` instance.N)Ú
isinstancer	   Z
_start_cmdÚstrÚbinary_location)r   r&   r   r   r   r%   ;   s    
c                 C   s   | j S )z%:Returns: The location of the binary.)r    r   r   r   r   r)   D   s    zOptions.binary_location)Úvaluer   c                 C   s   t |tƒst| jƒ‚|| _dS )z2Sets the location of the browser binary by string.N)r'   r(   Ú	TypeErrorZBINARY_LOCATION_ERRORr    )r   r*   r   r   r   r)   I   s    

c                 C   s   | j S )z :Returns: A dict of preferences.©r!   r   r   r   r   ÚpreferencesP   s    zOptions.preferences)Únamer*   c                 C   s   || j |< dS )zSets a preference.Nr,   )r   r.   r*   r   r   r   Úset_preferenceU   s    zOptions.set_preferencec                 C   s   | j S )z%:Returns: The Firefox profile to use.)r"   r   r   r   r   ÚprofileY   s    zOptions.profile)Únew_profiler   c                 C   s   t |tƒst|ƒ}|| _dS )z\Sets location of the browser profile to use, either by string or
        ``FirefoxProfile``.N)r'   r
   r"   )r   r1   r   r   r   r0   ^   s    
úorg.mozilla.firefox)Úandroid_packagec                    s   t ƒ  |||¡ d S r   )r   Úenable_mobile)r   r3   Zandroid_activityZdevice_serialr#   r   r   r4   f   s    zOptions.enable_mobilec                 C   s€   | j }i }| jr| j|d< | jr*| j|d< | jr<| jj|d< | jrL| j|d< | jr^| | j¡ | | j 	¡ ¡ |r|||t
j< |S )z>Marshals the Firefox options to a `moz:firefoxOptions` object.r%   Zprefsr0   Úargs)Z_capsr    r!   r"   ÚencodedZ
_argumentsZmobile_optionsÚupdater   r   r   ÚKEY)r   ZcapsÚoptsr   r   r   r   k   s     



zOptions.to_capabilitiesc                 C   s
   t j ¡ S r   )r   ZFIREFOXÚcopyr   r   r   r   Údefault_capabilities†   s    zOptions.default_capabilities)r2   NN)r   r   r   r8   r   Úpropertyr   r	   r%   Úsetterr   r(   r)   r   r-   ÚintÚboolr/   r   r
   r0   r4   r   r;   Ú__classcell__r   r   r#   r   r   (   s8   
     ÿÿr   N)Útypingr   r   r   r   Ztyping_extensionsr   Z.selenium.webdriver.common.desired_capabilitiesr   Z!selenium.webdriver.common.optionsr   Z)selenium.webdriver.firefox.firefox_binaryr	   Z*selenium.webdriver.firefox.firefox_profiler
   r   r   r   r   r   r   Ú<module>   s   
