
    i                     b    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)DriverFinder)LocalWebDriver)Options)SafariRemoteConnection)Servicec            	       d     e Zd ZdZ	 	 	 ddedz  dedz  deddf fdZ fdZd	 Z	d
 Z
d Z xZS )	WebDriverz>Controls the SafariDriver and allows you to drive the browser.Noptionsservice
keep_alivereturnc                 D   |r|n	t               | _        |r|n	t               | _        | j                  j	                         xs. t        | j                  | j                        j                         | j                  _        | j                  j                  s| j                  j                          t        | j                  j                  || j                  j                        }	 t        | 9  || j                         y# t        $ r | j!                           w xY w)a[  Create a new Safari driver instance and launch or find a running safaridriver service.

        Args:
            options: Instance of Options.
            service: Service object for handling the browser driver if you need to pass extra details.
            keep_alive: Whether to configure SafariRemoteConnection to use HTTP keep-alive.
        )remote_server_addrr   ignore_proxy)command_executorr   N)r   r   r   r   env_pathr   get_driver_pathpathreuse_servicestartr   service_url_ignore_local_proxysuper__init__	Exceptionquit)selfr   r   r   executor	__class__s        _/var/www/html/BatchJob/venv/lib/python3.12/site-packages/selenium/webdriver/safari/webdriver.pyr   zWebDriver.__init__   s     #*wwy")wwy LL113q|DLLRVR^R^7_7o7o7q||))LL )#||77!99
	GhM 	IIK	s   (D 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.quit>   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_permissionM   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_permissionU   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.debuge   s    &'K(r.   )NNT)__name__
__module____qualname____doc__r   r   r(   r   r   r-   r1   r5   __classcell__)r    s   @r!   r
   r
      sZ    H #'"&	4 4 	
 
B	$B )r.   r
   N)selenium.common.exceptionsr   'selenium.webdriver.common.driver_finderr   #selenium.webdriver.common.webdriverr   !selenium.webdriver.safari.optionsr   +selenium.webdriver.safari.remote_connectionr   !selenium.webdriver.safari.servicer   r
    r.   r!   <module>rB      s'   $ : @ > 5 N 5M) M)r.   