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 )
é    )ÚChromiumRemoteConnection)ÚDriverFinder)Ú
ArgOptions)ÚService)ÚCommand)Ú	WebDriverc                       s  e Zd ZdZddeƒ ddf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‡  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_pathZbinary_locationZbrowser_versionZenv_pathZget_driver_pathÚpathÚstartr   Zservice_urlZ_ignore_local_proxyÚsuperÚ__init__Ú	ExceptionÚquitZ
_is_remote)Úselfr	   r
   r   r   r   ÚfinderÚexecutor©Ú	__class__© úKE:\soccer\ml_env\Lib\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_appJ   s    zChromiumDriver.launch_appc                 C   s   |   d¡d S )zÉGets 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_conditionsN   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_conditionsW   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_conditionsj   s    z(ChromiumDriver.delete_network_conditions)Únamer    r   c                 C   s   |   dd|i|dœ¡ dS )zûSets 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_permissionsn   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)   r*   r   r   r   r+   |   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 )z¦Sets 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   r1   r   r   r   Úset_sink_to_use´   s    zChromiumDriver.set_sink_to_usec                 C   s   |   dd|i¡S )z—Starts a desktop mirroring session on a specific receiver target.

        :Args:
         - sink_name: Name of the sink to use as the target.
        ZstartDesktopMirroringr2   r   r3   r   r   r   Ústart_desktop_mirroring½   s    z&ChromiumDriver.start_desktop_mirroringc                 C   s   |   dd|i¡S )z“Starts a tab mirroring session on a specific receiver target.

        :Args:
         - sink_name: Name of the sink to use as the target.
        ZstartTabMirroringr2   r   r3   r   r   r   Ústart_tab_mirroringÅ   s    z"ChromiumDriver.start_tab_mirroringc                 C   s   |   dd|i¡S )z˜Stops the existing Cast session on a specific receiver target.

        :Args:
         - sink_name: Name of the sink to stop the Cast session.
        ZstopCastingr2   r   r3   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.quit)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ústrr   Úboolr   r   r"   r$   r%   r(   Údictr+   Úlistr,   r-   Úpropertyr.   r0   r4   r5   r6   r7   r   Ú__classcell__r   r   r   r   r      s<   úù,	
		r   N)Z-selenium.webdriver.chromium.remote_connectionr   Z'selenium.webdriver.common.driver_finderr   Z!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   