o
    Ò·hA  ã                   @   sf   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„Zdefdd„ZdS )ÚLogÚreturnNc                 C   s
   d | _ d S ©N©Úlevel©Úself© r   úU/var/www/html/venv/lib/python3.10/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©r   N)Ú__name__Ú
__module__Ú__qualname__r   Údictr   r   r   r   r   r      s    
r   c                       s  e Zd ZdZd‡ fdd„Zedefdd„ƒZejde	e
ef 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de
de	e
eef fdd„Zedefdd„ƒZejde	e
ef ddfdd„ƒZd de
f‡ fdd„Zdefdd„Zedefdd„ƒZ‡  ZS )!ÚOptionszmoz:firefoxOptionsr   Nc                    s(   t ƒ  ¡  d | _i | _d | _tƒ | _d S r	   )Úsuperr   Ú_binaryÚ_preferencesÚ_profiler   r   r   ©Ú	__class__r   r   r   '   s
   
zOptions.__init__c                 C   ó   | j S )z#Returns the FirefoxBinary instance.)r   r   r   r   r   Úbinary.   ó   zOptions.binaryÚ
new_binaryc                 C   ó   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    3   ó   

c                 C   s   | j jS )z%:Returns: The location of the binary.)r    Ú
_start_cmdr   r   r   r   Úbinary_location;   s   zOptions.binary_locationÚvaluec                 C   s   t |tƒs
t| jƒ‚|| _dS )z2Sets the location of the browser binary by string.N)r$   ÚstrÚ	TypeErrorÚBINARY_LOCATION_ERRORr    )r   r(   r   r   r   r'   @   s   


c                 C   r   )z :Returns: A dict of preferences.©r   r   r   r   r   ÚpreferencesG   r!   zOptions.preferencesÚnamec                 C   s   || j |< dS )zSets a preference.Nr,   )r   r.   r(   r   r   r   Úset_preferenceL   s   zOptions.set_preferencec                 C   r   )z%:Returns: The Firefox profile to use.)r   r   r   r   r   ÚprofileP   r!   zOptions.profileÚnew_profilec                 C   r#   )z\Sets location of the browser profile to use, either by string or
        ``FirefoxProfile``.N)r$   r   r   )r   r1   r   r   r   r0   U   r%   úorg.mozilla.firefoxÚandroid_packagec                    s   t ƒ  |||¡ d S r	   )r   Úenable_mobile)r   r3   Úandroid_activityÚdevice_serialr   r   r   r4   ]   s   zOptions.enable_mobilec                 C   s‚   | j }i }| jr| jj|d< | jr| j|d< | jr| jj|d< | jr'| j|d< | jr0| | j¡ | | j	 
¡ ¡ |r?||tj< |S )z>Marshals the Firefox options to a `moz:firefoxOptions` object.r    Úprefsr0   Úargs)Ú_capsr   r&   r   r   ÚencodedÚ
_argumentsÚmobile_optionsÚupdater   r   r   ÚKEY)r   ÚcapsÚoptsr   r   r   r   `   s    


zOptions.to_capabilitiesc                 C   s
   t j ¡ S r	   )r   ÚFIREFOXÚcopyr   r   r   r   Údefault_capabilities{   s   
zOptions.default_capabilitiesr   )r2   NN)r   r   r   r>   r   Úpropertyr   r    Úsetterr   r)   r'   r   r-   ÚintÚboolr/   r   r0   r4   r   rC   Ú__classcell__r   r   r   r   r   $   s,    r   )Útypingr   Ú.selenium.webdriver.common.desired_capabilitiesr   Ú!selenium.webdriver.common.optionsr   Ú)selenium.webdriver.firefox.firefox_binaryr   Ú*selenium.webdriver.firefox.firefox_profiler   r   r   r   r   r   r   Ú<module>   s   
