
    <gE                     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)    )WebDriverException)ClientConfig)	WebDriver   )DriverFinder   )Options)SafariRemoteConnection)Servicec                   T     e Zd ZdZ	 	 	 ddededdf fdZ f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                  |d      }t        |j                  |      }	 t        | 9  ||       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
        x   )remote_server_addr
keep_alivetimeout)ignore_proxyclient_config)command_executorr   FN)r   r   r	   env_pathr   get_driver_pathpathreuse_servicestartr   service_urlr
   _ignore_local_proxysuper__init__	Exceptionquit
_is_remote)selfr   r   r   r   executor	__class__s         W/var/www/html/myenv/lib/python3.12/site-packages/selenium/webdriver/safari/webdriver.pyr    zWebDriver.__init__   s     #*wwy$'') LL113l|DLLRY7Z7j7j7l||))LL $8P8P]gqtu) 44'

	GhH
  	  	IIK	s   C5 5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_PERMISSIONSr1   r,   )r/   r-   r.   )r$   r0   r2   r,   r1   s        r'   get_permissionzWebDriver.get_permission[   sM    ,,01':m,[(J'%&r4   c                 H    | j                  d       | j                  d       y )NATTACH_DEBUGGERz	debugger;)r/   execute_script)r$   s    r'   debugzWebDriver.debugk   s    &'K(r4   )TNN)__name__
__module____qualname____doc__r	   r   r    r"   r3   r7   r;   __classcell__)r&   s   @r'   r   r      sJ    H 	#  #  	# 
 
# J	$B )r4   r   N)selenium.common.exceptionsr   'selenium.webdriver.remote.client_configr   #selenium.webdriver.remote.webdriverr   RemoteWebDrivercommon.driver_finderr   r   r	   remote_connectionr
   r   r    r4   r'   <module>rH      s*   $ : @ L /  5 Q) Q)r4   