o
    US`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                	       sb   e Zd ZdZdededddddf	dedef 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r,t jdtdd |r6t jdtdd |s@t jdtdd |rJt jd	tdd || _|	rS|	| _n	t||||d
| _|sc| 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__ N/usr/local/lib/python3.10/dist-packages/selenium/webdriver/safari/webdriver.pyr   (   sV   

zWebDriver.__init__c                    sT   zzt    W n
 tjy   Y nw W | js| j  dS dS | js)| j  w w )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   
