a
    5ñ»jÁ  ã                   @   s\   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
„ d
eƒZdS )é    )ÚWebDriverException)Ú	WebDriveré   )ÚDriverFinderé   )ÚOptions)ÚSafariRemoteConnection)ÚServicec                       sP   e Zd ZdZdeeddœ‡ fdd„Z‡ fdd„Zd	d
„ Zdd„ Z	dd„ Z
‡  ZS )r   z>Controls the SafariDriver and allows you to drive the browser.TN)ÚoptionsÚserviceÚreturnc                    sž   |r|nt ƒ | _|r|ntƒ }| j ¡ p6t| j|ƒ ¡ | j_| jjsN| j ¡  t	| jj
||jd�}ztƒ j||d� W n ty’   |  ¡  ‚ Y n0 d| _dS )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
        )Zremote_server_addrÚ
keep_aliveZignore_proxy)Zcommand_executorr
   FN)r	   r   r   Zenv_pathr   Zget_driver_pathÚpathÚreuse_serviceÚstartr   Zservice_urlZ_ignore_local_proxyÚsuperÚ__init__Ú	ExceptionÚquitZ
_is_remote)Úselfr   r
   r   Úexecutor©Ú	__class__© úIE:\soccer\ml_env\Lib\site-packages\selenium/webdriver/safari/webdriver.pyr      s     
ýzWebDriver.__init__c                    sR   z8zt ƒ  ¡  W n ty"   Y n0 W | jjsN| j ¡  n| jjsL| j ¡  0 dS )z>Closes the browser and shuts down the SafariDriver executable.N)r   r   r   r   r   Ústop©r   r   r   r   r   C   s    ÿzWebDriver.quitc                 C   s.   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_permissionR   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_permissionZ   s    
zWebDriver.get_permissionc                 C   s   |   d¡ |  d¡ d S )NZATTACH_DEBUGGERz	debugger;)r    Zexecute_scriptr   r   r   r   Údebugj   s    
zWebDriver.debug)TNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r	   r   r   r$   r%   r&   Ú__classcell__r   r   r   r   r      s      üû%r   N)Zselenium.common.exceptionsr   Z#selenium.webdriver.remote.webdriverr   ZRemoteWebDriverZcommon.driver_finderr   r
   r   Zremote_connectionr   r   r	   r   r   r   r   Ú<module>   s   