a
    .c|                     @   s~   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 ddlmZmZ ddlmZ ej ZG d	d
 d
e
Z	dS )    N)WebDriverException)DesiredCapabilities)	WebDriver   )Options)DEFAULT_EXECUTABLE_PATHService)SafariRemoteConnectionc                	       s`   e Zd ZdZdededddddf	eed fddZ fd	d
Z	dd Z
dd Zdd Z  ZS )r   zI
    Controls the SafariDriver and allows you to drive the browser.

    r   FTN)optionsservicec
                    s   |rt jdtdd |tkr,t jdtdd |r@t jdtdd |tkrXt jdtdd |rlt jdtdd |st jdtdd |rt jd	tdd || _|	r|	| _nt||||d
| _|s| j  t	| jj
|d}
t j|
||d d| _dS )a	  

        Creates a new Safari driver instance and launches or finds a running safaridriver service.

        :Args:
         - port - The port on which the safaridriver service should listen for new connections. If zero, a free port will be found.
         - executable_path - Path to a custom safaridriver executable to be used. If absent, /usr/bin/safaridriver is used.
         - reuse_service - If True, do not spawn a safaridriver instance; instead, connect to an already-running service that was launched externally.
         - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Safari switches).
         - quiet - If True, the driver's stdout and stderr is suppressed.
         - keep_alive - Whether to configure SafariRemoteConnection to use
             HTTP keep-alive. Defaults to True.
         - service_args : List of args to pass to the safaridriver service
         - service - Service object for handling the browser driver if you need to pass extra details
        z=port has been deprecated, please set it via the service class   )
stacklevelzKexecutable_path has been deprecated, please use the Options class to set itzIreuse_service has been deprecated, please use the Service class to set itzPdesired_capabilities has been deprecated, please use the Options class to set itzAquiet has been deprecated, please use the Service class to set itzFkeep_alive has been deprecated, please use the Service class to set itzHservice_args has been deprecated, please use the Service class to set it)portquietservice_args)Zremote_server_addr
keep_alive)Zcommand_executorr
   desired_capabilitiesFN)warningswarnDeprecationWarningr   DEFAULT_SAFARI_CAPS_reuse_servicer   r   startr	   Zservice_urlsuper__init__Z
_is_remote)selfr   Zexecutable_pathZreuse_servicer   r   r   r   r
   r   executor	__class__ ]/var/www/brookimports/venv/lib/python3.9/site-packages/selenium/webdriver/safari/webdriver.pyr   (   sV    
zWebDriver.__init__c                    sP   z8zt    W n tjy$   Y n0 W | jsL| j  n| jsJ| j  0 dS )z
        Closes the browser and shuts down the SafariDriver executable
        that is started when starting the SafariDriver
        N)r   quithttp_clientBadStatusLiner   r   stopr   r   r   r    r!   d   s    zWebDriver.quitc                 C   s2   t |tstdi }|||< | dd|i d S )Nz;Value of a session permission must be set to True or False.ZSET_PERMISSIONSpermissions)
isinstanceboolr   execute)r   
permissionvaluepayloadr   r   r    set_permissionu   s
    
zWebDriver.set_permissionc                 C   sD   |  dd }|d }|sd S ||vr*d S || }t|ts@d S |S )NZGET_PERMISSIONSr+   r&   )r)   r'   r(   )r   r*   r,   r&   r+   r   r   r    get_permission~   s    
zWebDriver.get_permissionc                 C   s   |  d | d d S )NZATTACH_DEBUGGERz	debugger;)r)   Zexecute_scriptr%   r   r   r    debug   s    
zWebDriver.debug)__name__
__module____qualname____doc__r   r   r   r   r   r!   r-   r.   r/   __classcell__r   r   r   r    r   "   s   <	r   )http.clientclientr"   r   Zselenium.common.exceptionsr   Z.selenium.webdriver.common.desired_capabilitiesr   Z#selenium.webdriver.remote.webdriverr   ZRemoteWebDriverr
   r   r   r   r   Zremote_connectionr	   ZSAFARIcopyr   r   r   r   r    <module>   s   
