
    >fh                     n    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
 d dlmZ d dlmZ  G d d	e      Zy
)    )Optional)WebDriverException)DriverFinder)	WebDriver)Options)SafariRemoteConnection)Servicec                   l     e Zd ZdZ	 	 	 ddee   dee   ddf fdZ fdZd Z	d	 Z
d
 Zd Zd Z xZS )r   z>Controls the SafariDriver and allows you to drive the browser.Noptionsservicereturnc                    |r|n	t               | _        |r|n	t               }| j                  j                         xs$ t	        | j                  |      j                         | j                  _        | j                  j                  s| j                  j                          t        | j                  j                  ||j                        }	 t        | 5  ||       d| _        y# t        $ r | j                           w xY w)a  Creates a new Safari driver instance and launches or finds a running
        safaridriver service.

        :Args:
         - keep_alive - Whether to configure SafariRemoteConnection to use
             HTTP keep-alive. Defaults to True.
         - options - Instance of ``options.Options``.
         - service - Service object for handling the browser driver if you need to pass extra details
        )remote_server_addr
keep_aliveignore_proxy)command_executorr   FN)r	   r   r   env_pathr   get_driver_pathpathreuse_servicestartr   service_url_ignore_local_proxysuper__init__	Exceptionquit
_is_remote)selfr   r   r   executor	__class__s        V/var/www/zara/venv/lib/python3.12/site-packages/selenium/webdriver/safari/webdriver.pyr   zWebDriver.__init__   s     #*wwy$'') LL113l|DLLRY7Z7j7j7l||))LL )#||77! 44
	GhH
  	  	IIK	s   C( (Dc                    	 t         |           | j                  j                  s| j                  j                          yy# t        $ r Y =w xY w# | j                  j                  s| j                  j                          w w xY w)z>Closes the browser and shuts down the SafariDriver executable.N)r   r   r   r   r   stop)r   r!   s    r"   r   zWebDriver.quitD   sn    	$GLN
 <<--!!# .	  		 <<--!!# .s#   A 	AA AA 3Bc                 j    t        |t              st        d      ||i}| j                  dd|i       y )Nz;Value of a session permission must be set to True or False.SET_PERMISSIONSpermissions)
isinstanceboolr   execute)r   
permissionvaluepayloads       r"   set_permissionzWebDriver.set_permissionS   s6    %&$%bccu%&(@A    c                 t    | j                  d      d   }|d   }|sy ||vry ||   }t        |t              sy |S )NGET_PERMISSIONSr,   r'   )r*   r(   r)   )r   r+   r-   r'   r,   s        r"   get_permissionzWebDriver.get_permission[   sM    ,,01':m,[(J'%&r/   c                 H    | j                  d       | j                  d       y )NATTACH_DEBUGGERz	debugger;)r*   execute_script)r   s    r"   debugzWebDriver.debugk   s    &'K(r/   c                     t         NNotImplementedErrorr   argskwargss      r"   download_filezWebDriver.download_fileo       !!r/   c                     t         r8   r9   r;   s      r"   get_downloadable_filesz WebDriver.get_downloadable_filesr   r?   r/   )TNN)__name__
__module____qualname____doc__r   r   r	   r   r   r.   r2   r6   r>   rA   __classcell__)r!   s   @r"   r   r      s^    H %)%)	#  '"#  '"	# 
 
# J	$B )""r/   r   N)typingr   selenium.common.exceptionsr   'selenium.webdriver.common.driver_finderr   #selenium.webdriver.remote.webdriverr   RemoteWebDriver!selenium.webdriver.safari.optionsr   +selenium.webdriver.safari.remote_connectionr   !selenium.webdriver.safari.servicer	    r/   r"   <module>rP      s*   $  9 @ L 5 N 5W" W"r/   