o
    US`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defddZdS )Logc                 C   s
   d | _ d S Nlevelself r   M/usr/local/lib/python3.10/dist-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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edefddZejde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: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      | j S )z"Returns the FirefoxBinary instance)r   r   r   r   r   binary.      zOptions.binary
new_binaryNc                 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   r   )z :Returns: A dict of preferences.r   r   r   r   r   preferencesI   r!   zOptions.preferencesnamec                 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/   r0   r1   r#   r   r   )r   r3   r   r   r   r2   _   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   s2   |r
| j d dS d| j v r| j d dS dS )z
        Sets the headless argument

        Args:
          value: boolean value indicating to set the headless option
        r4   N)r5   appendremover'   r   r   r   r6   u   s
   
org.mozilla.firefoxandroid_packagec                    s   t  ||| d S r   )r   enable_mobile)r   r:   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r(| jj|d< | jr0| j|d< | j	r9|
| j	 |
| j  |rH||tj< |S )zOMarshals the Firefox options to a `moz:firefoxOptions`
        object.
        r    Zprefsr2   args)Z_capsr   r$   r   r   Zadd_to_capabilitiesr   encodedr5   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)r9   NN)r   r   r   r?   r   propertyr   r    setterr   strr%   r   r)   intboolr+   r   r2   r6   r;   r   rB   __classcell__r   r   r   r   r   #   s4    	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   
