a
    &h                      @   sh   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	 d	eZd
S )    )Optional)ChromiumRemoteConnection)DriverFinder)
ArgOptions)Service)Command)	WebDriverc                       s(  e Zd ZdZdde ddfee ee eee edd fddZ	dd Z
d	d
 ZddddZddddZeeddddZeed fddZedddZdd Zedd Zdd Zeeddd Zeedd!d"Zeedd#d$Zeedd%d&Zdd fd'd(Zd)d* Zd+d, Z  ZS )-ChromiumDriverzZControls the WebDriver instance of ChromiumDriver and allows you to
    drive the browser.NT)browser_namevendor_prefixoptionsservice
keep_alivereturnc                    s   || _ t| j |}| r*| |_d|_| j  p:| | j _| j   t	| j j
||||jd}zt j||d W n ty   |    Y n0 d| _dS )aU  Creates a new WebDriver instance of the ChromiumDriver. Starts the
        service and then creates new WebDriver instance of ChromiumDriver.

        :Args:
         - browser_name - Browser name used when matching capabilities.
         - vendor_prefix - Company prefix to apply to vendor-specific WebDriver extension commands.
         - options - this takes an instance of ChromiumOptions
         - service - Service object for handling the browser driver if you need to pass extra details
         - keep_alive - Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
        N)Zremote_server_addrr
   r   r   Zignore_proxy)Zcommand_executorr   F)r   r   Zget_browser_pathbinary_locationbrowser_versionenv_pathZget_driver_pathpathstartr   service_url_ignore_local_proxysuper__init__	ExceptionquitZ
_is_remote)selfr
   r   r   r   r   finderexecutor	__class__ j/var/www/html/swiplay.fr/scambot/venv/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.pyr       s(    

zChromiumDriver.__init__c                 C   s   |  dd|iS )z&Launches Chromium app specified by id.Z	launchAppidexecute)r   r"   r    r    r!   
launch_appL   s    zChromiumDriver.launch_appc                 C   s   |  dd S )zGets Chromium network emulation settings.

        :Returns:
            A dict.
            For example:     {'latency': 4, 'download_throughput': 2, 'upload_throughput': 2, 'offline': False}
        ZgetNetworkConditionsvaluer#   r   r    r    r!   get_network_conditionsP   s    z%ChromiumDriver.get_network_conditions)r   c                 K   s   |  dd|i dS )a+  Sets Chromium network emulation settings.

        :Args:
         - network_conditions: A dict with conditions specification.

        :Usage:
            ::

                driver.set_network_conditions(
                    offline=False,
                    latency=5,  # additional latency (ms)
                    download_throughput=500 * 1024,  # maximal throughput
                    upload_throughput=500 * 1024,
                )  # maximal throughput

            Note: 'throughput' can be used to set both (for download and upload).
        ZsetNetworkConditionsnetwork_conditionsNr#   )r   r)   r    r    r!   set_network_conditionsY   s    z%ChromiumDriver.set_network_conditionsc                 C   s   |  d dS )z+Resets Chromium network emulation settings.ZdeleteNetworkConditionsNr#   r'   r    r    r!   delete_network_conditionsm   s    z(ChromiumDriver.delete_network_conditions)namer&   r   c                 C   s   |  dd|i|d dS )zSets Applicable Permission.

        :Args:
         - name: The item to set the permission on.
         - value: The value to set on the item

        :Usage:
            ::

                driver.set_permissions("clipboard-read", "denied")
        ZsetPermissionsr,   )Z
descriptorstateNr#   )r   r,   r&   r    r    r!   set_permissionsq   s    zChromiumDriver.set_permissions)cmdcmd_argsc                    s   t  ||S )a  Execute Chrome Devtools Protocol command and get returned result The
        command and command args should follow chrome devtools protocol
        domains/commands, refer to link
        https://chromedevtools.github.io/devtools-protocol/

        :Args:
         - cmd: A str, command name
         - cmd_args: A dict, command args. empty dict {} if there is no command args
        :Usage:
            ::

                driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': requestId})
        :Returns:
            A dict, empty dict {} if there is no result to return.
            For example to getResponseBody:
            {'base64Encoded': False, 'body': 'response body string'}
        )r   execute_cdp_cmd)r   r/   r0   r   r    r!   r1      s    zChromiumDriver.execute_cdp_cmdc                 C   s   |  dd S )z-:Returns: A list of sinks available for Cast.ZgetSinksr&   r#   r'   r    r    r!   	get_sinks   s    zChromiumDriver.get_sinksc                 C   s   |  dd S )zM:Returns: An error message when there is any issue in a Cast
        session.ZgetIssueMessager&   r#   r'   r    r    r!   get_issue_message   s    z ChromiumDriver.get_issue_messagec                 C   s   |  tjd S )zpGets a list of the available log types.

        Example:
        --------
        >>> driver.log_types
        r&   )r$   r   ZGET_AVAILABLE_LOG_TYPESr'   r    r    r!   	log_types   s    zChromiumDriver.log_typesc                 C   s   |  tjd|id S )aY  Gets the log for a given log type.

        Parameters:
        -----------
        log_type : str
            - Type of log that which will be returned

        Example:
        --------
        >>> driver.get_log("browser")
        >>> driver.get_log("driver")
        >>> driver.get_log("client")
        >>> driver.get_log("server")
        typer&   )r$   r   ZGET_LOG)r   Zlog_typer    r    r!   get_log   s    zChromiumDriver.get_log)	sink_namer   c                 C   s   |  dd|iS )zSets a specific sink, using its name, as a Cast session receiver
        target.

        :Args:
         - sink_name: Name of the sink to use as the target.
        ZsetSinkToUsesinkNamer#   r   r7   r    r    r!   set_sink_to_use   s    zChromiumDriver.set_sink_to_usec                 C   s   |  dd|iS )zStarts a desktop mirroring session on a specific receiver target.

        :Args:
         - sink_name: Name of the sink to use as the target.
        ZstartDesktopMirroringr8   r#   r9   r    r    r!   start_desktop_mirroring   s    z&ChromiumDriver.start_desktop_mirroringc                 C   s   |  dd|iS )zStarts a tab mirroring session on a specific receiver target.

        :Args:
         - sink_name: Name of the sink to use as the target.
        ZstartTabMirroringr8   r#   r9   r    r    r!   start_tab_mirroring   s    z"ChromiumDriver.start_tab_mirroringc                 C   s   |  dd|iS )zStops the existing Cast session on a specific receiver target.

        :Args:
         - sink_name: Name of the sink to stop the Cast session.
        ZstopCastingr8   r#   r9   r    r    r!   stop_casting   s    zChromiumDriver.stop_castingc                    sB   z0zt    W n ty"   Y n0 W | j  n| j  0 dS )z@Closes the browser and shuts down the ChromiumDriver executable.N)r   r   r   r   stopr'   r   r    r!   r      s
    zChromiumDriver.quitc                 O   s   t d S NNotImplementedErrorr   argskwargsr    r    r!   download_file   s    zChromiumDriver.download_filec                 O   s   t d S r?   r@   rB   r    r    r!   get_downloadable_files   s    z%ChromiumDriver.get_downloadable_files)__name__
__module____qualname____doc__r   r   strr   boolr   r%   r(   r*   r+   r.   dictr1   listr2   r3   propertyr4   r6   r:   r;   r<   r=   r   rE   rF   __classcell__r    r    r   r!   r	      s@   ,	
		
r	   N)typingr   Z-selenium.webdriver.chromium.remote_connectionr   Z'selenium.webdriver.common.driver_finderr   !selenium.webdriver.common.optionsr   Z!selenium.webdriver.common.servicer   Z!selenium.webdriver.remote.commandr   Z#selenium.webdriver.remote.webdriverr   ZRemoteWebDriverr	   r    r    r    r!   <module>   s   