o
    ҷhq                     @   sP   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)	WebDriverc                       s   e Zd ZdZ	d(dededdf fddZd	d
 Zdd Zd)ddZ	d)ddZ
dededdfddZdedefddZdef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d) fd&d'Z  ZS )*ChromiumDriverzZControls the WebDriver instance of ChromiumDriver and allows you to
    drive the browser.ToptionsservicereturnNc                    st   || _ || _t| j|| j_| j  zt jt| jj	||||j
d|d W n ty4   |    w 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.
        )remote_server_addrbrowser_namevendor_prefix
keep_aliveignore_proxy)command_executorr   FN)r   r	   r   get_pathpathstartsuper__init__r   service_url_ignore_local_proxy	Exceptionquit
_is_remote)selfr   r   r   r	   r   	__class__ X/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.pyr      s(   



zChromiumDriver.__init__c                 C      |  dd|iS )z&Launches Chromium app specified by id.	launchAppidexecute)r   r"   r   r   r   
launch_appG   s   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,     'offline':
        False}
        getNetworkConditionsvaluer#   r   r   r   r   get_network_conditionsK   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.

        :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).
        setNetworkConditionsnetwork_conditionsNr#   )r   r,   r   r   r   set_network_conditionsT   s   z%ChromiumDriver.set_network_conditionsc                 C   s   |  d dS )z+Resets Chromium network emulation settings.deleteNetworkConditionsNr#   r)   r   r   r   delete_network_conditionsg      z(ChromiumDriver.delete_network_conditionsnamer(   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')
        setPermissionsr1   )
descriptorstateNr#   )r   r1   r(   r   r   r   set_permissionsk   s   zChromiumDriver.set_permissionscmdcmd_argsc                 C   s   |  d||dd 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'}
        executeCdpCommand)r6   paramsr(   r#   )r   r6   r7   r   r   r   execute_cdp_cmdy   s   zChromiumDriver.execute_cdp_cmdc                 C   r&   )z-:Returns: A list of sinks available for Cast.getSinksr(   r#   r)   r   r   r   	get_sinks   r0   zChromiumDriver.get_sinksc                 C   r&   )zM:Returns: An error message when there is any issue in a Cast
        session.getIssueMessager(   r#   r)   r   r   r   get_issue_message   s   z ChromiumDriver.get_issue_message	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   r?   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.
        startDesktopMirroringrA   r#   rB   r   r   r   start_desktop_mirroring      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.
        startTabMirroringrA   r#   rB   r   r   r   start_tab_mirroring   rF   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.
        stopCastingrA   r#   rB   r   r   r   stop_casting   rF   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 )zyCloses the browser and shuts down the ChromiumDriver executable that
        is started when starting the ChromiumDriver.N)r   r   r   r	   stopr)   r   r   r   r      s   zChromiumDriver.quit)T)r
   N)__name__
__module____qualname____doc__r   r   r   r%   r*   r-   r/   strr5   dictr:   listr<   r>   rC   rE   rH   rJ   r   __classcell__r   r   r   r   r      s.    	*
	
	r   N)-selenium.webdriver.chromium.remote_connectionr   'selenium.webdriver.common.driver_finderr   !selenium.webdriver.common.optionsr   !selenium.webdriver.common.servicer   #selenium.webdriver.remote.webdriverr   RemoteWebDriverr   r   r   r   r   <module>   s   