U
    g                     @   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-3ysq0mf8/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   
