o
    M,hj"                     @   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)ChromiumOptions)ChromiumRemoteConnection)ChromiumService)DriverFinder)Command)	WebDriverc                       s>  e Zd ZdZ					d5dee dee dee dee ded	df fd
dZ	dd Z
dd Zd6ddZd6ddZdeded	dfddZdedef fddZd	efddZdd Zed d! Zd"d# Zd$ed	efd%d&Zd$ed	efd'd(Zd$ed	efd)d*Zd$ed	efd+d,Zd6 fd-d.Zd/d0 Zd1d2 Zd3d4 Z  ZS )7ChromiumDriverzZControls the WebDriver instance of ChromiumDriver and allows you to
    drive the browser.NTbrowser_namevendor_prefixoptionsservice
keep_alivereturnc                    s   |r|nt  | _|r|nt }t| j|}| r!| |_d|_| j p)| | j_	| j
  t| jj||||jd}z
t j||d W n tyS   |    w d| _dS )aV  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)remote_server_addrr
   r   r   ignore_proxy)command_executorr   F)r   r   r   r   get_browser_pathbinary_locationbrowser_versionenv_pathget_driver_pathpathstartr   service_url_ignore_local_proxysuper__init__	Exceptionquit
_is_remote)selfr
   r   r   r   r   finderexecutor	__class__ q/var/www/www-root/data/www/bot.pdev.uz/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.pyr       s,   


zChromiumDriver.__init__c                 C      |  dd|iS )ztLaunches Chromium app specified by id.

        Args:
            id: The id of the Chromium app to launch.
        	launchAppidexecute)r!   r*   r&   r&   r'   
launch_appN      zChromiumDriver.launch_appc                 C      |  dd S )zGets Chromium network emulation settings.

        Returns:
            A dict. For example: {'latency': 4, 'download_throughput': 2, 'upload_throughput': 2}
        getNetworkConditionsvaluer+   r!   r&   r&   r'   get_network_conditionsV   s   z%ChromiumDriver.get_network_conditionsc                 K   s   |  dd|i dS )a  Sets Chromium network emulation settings.

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

        Example:
            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).
        setNetworkConditionsnetwork_conditionsNr+   )r!   r5   r&   r&   r'   set_network_conditions^   s   z%ChromiumDriver.set_network_conditionsc                 C   s   |  d dS )z+Resets Chromium network emulation settings.deleteNetworkConditionsNr+   r2   r&   r&   r'   delete_network_conditionsp   s   z(ChromiumDriver.delete_network_conditionsnamer1   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

        Example:
            driver.set_permissions("clipboard-read", "denied")
        setPermissionsr9   )
descriptorstateNr+   )r!   r9   r1   r&   r&   r'   set_permissionst   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

        Example:
            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   r/   )zJ
        Returns:
            A list of sinks available for Cast.
        getSinksr1   r+   r2   r&   r&   r'   	get_sinks      zChromiumDriver.get_sinksc                 C   r/   )zb
        Returns:
            An error message when there is any issue in a Cast session.
        getIssueMessager1   r+   r2   r&   r&   r'   get_issue_message   rC   z ChromiumDriver.get_issue_messagec                 C   s   |  tjd S )zpGets a list of the available log types.

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

        Args:
            log_type: 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")
        typer1   )r,   r   GET_LOG)r!   log_typer&   r&   r'   get_log   s   zChromiumDriver.get_log	sink_namec                 C   r(   )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.
        setSinkToUsesinkNamer+   r!   rL   r&   r&   r'   set_sink_to_use   s   zChromiumDriver.set_sink_to_usec                 C   r(   )zStarts a desktop mirroring session on a specific receiver target.

        Args:
            sink_name: Name of the sink to use as the target.
        startDesktopMirroringrN   r+   rO   r&   r&   r'   start_desktop_mirroring   r.   z&ChromiumDriver.start_desktop_mirroringc                 C   r(   )zStarts a tab mirroring session on a specific receiver target.

        Args:
            sink_name: Name of the sink to use as the target.
        startTabMirroringrN   r+   rO   r&   r&   r'   start_tab_mirroring   r.   z"ChromiumDriver.start_tab_mirroringc                 C   r(   )zStops the existing Cast session on a specific receiver target.

        Args:
            sink_name: Name of the sink to stop the Cast session.
        stopCastingrN   r+   rO   r&   r&   r'   stop_casting   r.   zChromiumDriver.stop_castingc                    sP   z!zt    W n	 ty   Y n	w W | j  dS W | j  dS | j  w )z@Closes the browser and shuts down the ChromiumDriver executable.N)r   r   r   r   stopr2   r$   r&   r'   r      s   zChromiumDriver.quitc                 O      t )zCDownload file functionality is not implemented for Chromium driver.NotImplementedErrorr!   argskwargsr&   r&   r'   download_file      zChromiumDriver.download_filec                 O   rX   )zLGet downloadable files functionality is not implemented for Chromium driver.rY   r[   r&   r&   r'   get_downloadable_files   r_   z%ChromiumDriver.get_downloadable_filesc                 O   rX   )zODelete downloadable files functionality is not implemented for Chromium driver.rY   r[   r&   r&   r'   delete_downloadable_files   r_   z(ChromiumDriver.delete_downloadable_files)NNNNT)r   N) __name__
__module____qualname____doc__r   strr   r   boolr   r-   r3   r6   r8   r=   dictr@   listrB   rE   propertyrG   rK   rP   rR   rT   rV   r   r^   r`   ra   __classcell__r&   r&   r$   r'   r	      sN    .


		
r	   N)typingr   #selenium.webdriver.chromium.optionsr   -selenium.webdriver.chromium.remote_connectionr   #selenium.webdriver.chromium.servicer   'selenium.webdriver.common.driver_finderr   !selenium.webdriver.remote.commandr   #selenium.webdriver.remote.webdriverr   RemoteWebDriverr	   r&   r&   r&   r'   <module>   s   