a
    Šxd4  ã                   @   sn   d dl 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 d dl	m
Z
 G dd„ dƒZG d	d
„ d
eƒZdS )é    N)ÚUnion)Ú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   úZ/var/www/html/Ranjet/env/lib/python3.9/site-packages/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                       s6  e Zd ZdZddœ‡ fdd„Zeedœdd„ƒZej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dœdd„ƒZeje	e
ef ddœdd„ƒZeedœdd„ƒZejed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:firefoxOptionsNr   c                    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__c                 C   s   | j S )z#Returns the FirefoxBinary instance.)r   r   r   r   r   Úbinary0   s    zOptions.binary)Ú
new_binaryr	   c                 C   s   t |tƒst|ƒ}|| _dS )z\Sets location of the browser binary, either by string or
        ``FirefoxBinary`` instance.N)Ú
isinstancer   r   )r   r!   r   r   r   r    5   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)Úvaluer	   c                 C   s
   || _ dS )z2Sets 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_profiler	   c                 C   s,   t jdtdd t|tƒs"t|ƒ}|| _dS )z\Sets 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   t jdtdd d| jv S )zL
        :Returns: True if the headless argument is set, else False
        zKheadless property is deprecated, instead check for '-headless' in argumentsr+   r,   ú	-headless)r.   r/   r0   Ú
_argumentsr   r   r   r   Úheadlessh   s    ýzOptions.headlessc                 C   s<   t jdtdd |r"| j d¡ nd| jv r8| j d¡ dS )zxSets the headless argument.

        Args:
          value: boolean value indicating to set the headless option
        zFheadless property is deprecated, instead use add_argument('-headless')r+   r,   r3   N)r.   r/   r0   r4   ÚappendÚremover&   r   r   r   r5   t   s    ÿ
úorg.mozilla.firefox)Ú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 )z>Marshals 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.common.optionsr   Z)selenium.webdriver.firefox.firefox_binaryr   Z*selenium.webdriver.firefox.firefox_profiler   r   r   r   r   r   r   Ú<module>   s   
