B
     ¸hì  ã               @   sh   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eƒZG d	d
„ d
eƒZdS )é    N)ÚInvalidArgumentException)ÚDesiredCapabilities)ÚProxy)ÚFirefoxBinary)ÚFirefoxProfilec               @   s   e Zd Zdd„ Zdd„ ZdS )ÚLogc             C   s
   d | _ d S )N)Úlevel)Úself© r
   ú_C:\Users\sanjo\AppData\Local\Qlobot\Launcher\ext_packages\selenium\webdriver\firefox\options.pyÚ__init__   s    zLog.__init__c             C   s   | j d k	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   r   r
   r
   r
   r   r      s   r   c               @   s  e Zd ZdZdd„ Zedd„ ƒZejdd„ ƒZedd„ ƒZejd	d„ ƒZed
d„ ƒZ	e	jdd„ ƒZ	edd„ ƒZ
dd„ Zedd„ ƒZdd„ Zedd„ ƒZejdd„ ƒZedd„ ƒZejdd„ ƒZedd„ ƒZdd„ Zedd „ ƒZejd!d „ ƒZd(d#d$„Zd%d&„ Zd'S ))ÚOptionszmoz:firefoxOptionsc             C   s6   d | _ i | _d | _d | _tj ¡ | _g | _t	ƒ | _
d S )N)Ú_binaryÚ_preferencesÚ_profileÚ_proxyr   ÚFIREFOXÚcopyÚ_capsÚ
_argumentsr   r   )r	   r
   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.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	   Z
new_binaryr
   r
   r   r   5   s    
c             C   s   | j jS )z#Returns the location of the binary.)r   Ú
_start_cmd)r	   r
   r
   r   Úbinary_location?   s    zOptions.binary_locationc             C   s
   || _ dS )z3 Sets the location of the browser binary by string N)r   )r	   Úvaluer
   r
   r   r   D   s    c             C   s   | j  d¡S )NÚacceptInsecureCerts)r   Úget)r	   r
   r
   r   Úaccept_insecure_certsI   s    zOptions.accept_insecure_certsc             C   s   || j d< d S )Nr    )r   )r	   r   r
   r
   r   r"   M   s    c             C   s   | j S )N)r   )r	   r
   r
   r   ÚcapabilitiesQ   s    zOptions.capabilitiesc             C   s   || j |< dS )zSets a capability.N)r   )r	   Únamer   r
   r
   r   Úset_capabilityU   s    zOptions.set_capabilityc             C   s   | j S )zReturns a dict of preferences.)r   )r	   r
   r
   r   ÚpreferencesY   s    zOptions.preferencesc             C   s   || j |< dS )zSets a preference.N)r   )r	   r$   r   r
   r
   r   Úset_preference^   s    zOptions.set_preferencec             C   s   | j S )z% returns Proxy if set otherwise None.)r   )r	   r
   r
   r   Úproxyb   s    zOptions.proxyc             C   s   t |tƒstdƒ‚|| _d S )Nz$Only Proxy objects can be passed in.)r   r   r   r   )r	   r   r
   r
   r   r(   g   s    
c             C   s   | j S )z#Returns the Firefox profile to use.)r   )r	   r
   r
   r   Úprofilem   s    zOptions.profilec             C   s   t |tƒst|ƒ}|| _dS )zfSets location of the browser profile to use, either by string
        or ``FirefoxProfile``.

        N)r   r   r   )r	   Znew_profiler
   r
   r   r)   r   s    
c             C   s   | j S )z,Returns a list of browser process arguments.)r   )r	   r
   r
   r   Ú	arguments|   s    zOptions.argumentsc             C   s   |dkrt ƒ ‚| j |¡ dS )z0Add argument to be used for the browser process.N)Ú
ValueErrorr   Úappend)r	   Úargumentr
   r
   r   Úadd_argument   s    zOptions.add_argumentc             C   s
   d| j kS )zE
        Returns whether or not the headless argument is set
        z	-headless)r   )r	   r
   r
   r   Úheadless‡   s    zOptions.headlessc             C   s0   |dkr| j  d¡ nd| j kr,| j  d¡ dS )z€
        Sets the headless argument

        Args:
          value: boolean value indicating to set the headless option
        Tz	-headlessN)r   r,   Úremove)r	   r   r
   r
   r   r/   Ž   s    
Tc             C   s   t jdtdd || _dS )z% Deprecated, options.headless = True z8use setter for headless property instead of set_headlessé   )Ú
stacklevelN)ÚwarningsÚwarnÚDeprecationWarningr/   )r	   r/   r
   r
   r   Úset_headless›   s    
zOptions.set_headlessc             C   s¦   | j }i }| jdk	r | jj|d< t| jƒdkr8| j|d< | jdk	rN| j |¡ | jdk	rd| jj|d< t| j	ƒdkr|| j	|d< | 
| j ¡ ¡ t|ƒdkr¢||tj< |S )zPMarshals the Firefox options to a `moz:firefoxOptions`
        object.

        Nr   r   Úprefsr)   Úargs)r   r   r   Úlenr   r   Úadd_to_capabilitiesr   Úencodedr   Úupdater   r   r   ÚKEY)r	   ÚcapsÚoptsr
   r
   r   r   ¡   s     	





zOptions.to_capabilitiesN)T)r   r   r   r=   r   Úpropertyr   Úsetterr   r"   r#   r%   r&   r'   r(   r)   r*   r.   r/   r6   r   r
   r
   r
   r   r   $   s,   	


r   )r3   Zselenium.common.exceptionsr   Ú.selenium.webdriver.common.desired_capabilitiesr   Úselenium.webdriver.common.proxyr   Ú)selenium.webdriver.firefox.firefox_binaryr   Z*selenium.webdriver.firefox.firefox_profiler   Úobjectr   r   r
   r
   r
   r   Ú<module>   s   
