a
    ¾Ê.c   ã                   @   sf   d dl mZ 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ƒZG d	d
„ d
e
ƒZdS )é    )ÚUnionN)ÚDesiredCapabilities)ÚFirefoxBinary)ÚFirefoxProfile)Ú
ArgOptionsc                   @   s"   e Zd Zdd„ Zedœdd„ZdS )ÚLogc                 C   s
   d | _ d S ©N©Úlevel©Úself© r   ú\/var/www/brookimports/venv/lib/python3.9/site-packages/selenium/webdriver/firefox/options.pyÚ__init__   s    zLog.__init__©Úreturnc                 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_capabilitiesN)Ú__name__Ú
__module__Ú__qualname__r   Údictr   r   r   r   r   r      s   r   c                       s(  e Zd ZdZ‡ fdd„Zeedœdd„ƒZeje	e
ef dœdd„ƒZee
dœd	d
„ƒZeje
dœdd
„ƒZeedœdd„ƒZe
e	e
eef dœdd„Zeedœdd„ƒZeje	e
ef dœdd„ƒZeedœdd„ƒZejedœdd„ƒZd"e
dœ‡ fdd„Zedœdd„Zeedœd d!„ƒZ‡  ZS )#ÚOptionszmoz:firefoxOptionsc                    s.   t ƒ  ¡  d | _i | _d | _d | _tƒ | _d S r   )Úsuperr   Ú_binaryÚ_preferencesÚ_profileÚ_proxyr   r   r   ©Ú	__class__r   r   r   &   s    
zOptions.__init__r   c                 C   s   | j S )z"Returns the FirefoxBinary instance)r   r   r   r   r   Úbinary.   s    zOptions.binary)Ú
new_binaryc                 C   s   t |tƒst|ƒ}|| _dS )zfSets location of the browser binary, either by string or
        ``FirefoxBinary`` instance.

        N)Ú
isinstancer   r   )r   r!   r   r   r   r    3   s    
c                 C   s   | j jS )z7
        :Returns: The location of the binary.
        )r    Ú
_start_cmdr   r   r   r   Úbinary_location=   s    zOptions.binary_location)Úvaluec                 C   s
   || _ dS )z3 Sets the location of the browser binary by string N)r    ©r   r%   r   r   r   r$   D   s    c                 C   s   | j S )z :Returns: A dict of preferences.©r   r   r   r   r   ÚpreferencesI   s    zOptions.preferences)Únamer%   c                 C   s   || j |< dS )zSets a preference.Nr'   )r   r)   r%   r   r   r   Úset_preferenceN   s    zOptions.set_preferencec                 C   s   | j rtjdtdd | j S )z7
        :Returns: The Firefox profile to use.
        z&Getting a profile has been deprecated.é   ©Ú
stacklevel)r   ÚwarningsÚwarnÚDeprecationWarningr   r   r   r   ÚprofileR   s    ýzOptions.profile)Únew_profilec                 C   s,   t jdtdd t|tƒs"t|ƒ}|| _dS )zfSets location of the browser profile to use, either by string
        or ``FirefoxProfile``.

        z_Setting a profile has been deprecated. Please use the set_preference and install_addons methodsr+   r,   N)r.   r/   r0   r"   r   r   )r   r2   r   r   r   r1   _   s    ý
c                 C   s
   d| j v S )zL
        :Returns: True if the headless argument is set, else False
        ú	-headless)Ú
_argumentsr   r   r   r   Úheadlessn   s    zOptions.headlessc                 C   s,   |r| j  d¡ nd| j v r(| j  d¡ dS )z€
        Sets the headless argument

        Args:
          value: boolean value indicating to set the headless option
        r3   N)r4   ÚappendÚremover&   r   r   r   r5   u   s    
úorg.mozilla.firefoxN)Úandroid_packagec                    s   t ƒ  |||¡ d S r   )r   Úenable_mobile)r   r9   Zandroid_activityZdevice_serialr   r   r   r:   ‚   s    zOptions.enable_mobilec                 C   s”   | j }i }| jr| jj|d< | jr,| j|d< | jr>| j |¡ | jrP| jj|d< | jr`| j|d< | j	rr| 
| j	¡ | 
| j ¡ ¡ |r||tj< |S )zOMarshals the Firefox options to a `moz:firefoxOptions`
        object.
        r    Zprefsr1   Úargs)Z_capsr   r#   r   r   Zadd_to_capabilitiesr   Úencodedr4   Zmobile_optionsÚupdater   r   r   ÚKEY)r   ZcapsÚoptsr   r   r   r   …   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)r8   NN)r   r   r   r>   r   Úpropertyr   r    Úsetterr   Ústrr$   r   r(   ÚintÚboolr*   r   r1   r5   r:   r   rA   Ú__classcell__r   r   r   r   r   #   s2   	r   )Útypingr   r.   Z.selenium.webdriver.common.desired_capabilitiesr   Z)selenium.webdriver.firefox.firefox_binaryr   Z*selenium.webdriver.firefox.firefox_profiler   Z!selenium.webdriver.common.optionsr   r   r   r   r   r   r   Ú<module>   s   
