o
    Vh                     @   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                       sZ   e Zd ZdZ			ddededdf 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 }t| j|| j_| jjs!| j  t| jj	||j
d}z
t j||d W n tyA   |    w 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
        )remote_server_addr
keep_aliveignore_proxy)command_executorr
   FN)r	   r   r   r   get_pathpathreuse_servicestartr   service_url_ignore_local_proxysuper__init__	Exceptionquit
_is_remote)selfr   r
   r   executor	__class__ `/home/air/yokohama/back/venv/lib/python3.10/site-packages/selenium/webdriver/safari/webdriver.pyr      s"   

zWebDriver.__init__c                    sV   zzt    W n	 ty   Y nw W | jjs| j  dS dS | jjs*| j  w w )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.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 )N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 )NATTACH_DEBUGGERz	debugger;)r(   execute_scriptr#   r    r    r!   debugj   s   
zWebDriver.debug)TNN)__name__
__module____qualname____doc__r   r	   r   r   r,   r.   r1   __classcell__r    r    r   r!   r      s     %r   N)selenium.common.exceptionsr   #selenium.webdriver.remote.webdriverr   RemoteWebDrivercommon.driver_finderr   r
   r   remote_connectionr   r   r	   r    r    r    r!   <module>   s   