a
    .c$                     @   sp   d dl mZ d dlmZ d dlmZ d dlmZ d dl	Z	d dl
mZ d dlmZ d ZdZdZG dd deZdS )	    )BaseOptions)Service)OptionsN)ChromiumRemoteConnection)	WebDriverc                       s   e Zd ZdZedddedefee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ddZed
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ed
d$d%Z  ZS )&ChromiumDriverz`
    Controls the WebDriver instance of ChromiumDriver and allows you to drive the browser.
    N)optionsservicec
                    s$  |rt jdtdd |tkr,t jdtdd || _|tkrJt jdtdd |	tkrpt|  krpt jdtdd nd}	|| _d}
|s| 	 }|r|
 D ]\}}||| q|jr|j}
|std	|| _| j  z&t jt| jj|||	|
d
|d W n ty   |    Y n0 d| _dS )a  
        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.
         - port - Deprecated: port you would like the service to run, if left as 0, a free port will be found.
         - options - this takes an instance of ChromiumOptions
         - service_args - Deprecated: List of args to pass to the driver service
         - desired_capabilities - Deprecated: Dictionary object with non-browser specific
           capabilities only, such as "proxy" or "loggingPref".
         - service_log_path - Deprecated: Where to log information from the driver.
         - keep_alive - Deprecated: Whether to configure ChromiumRemoteConnection to use HTTP keep-alive.
        zIdesired_capabilities has been deprecated, please pass in a Service object   )
stacklevelz9port has been deprecated, please pass in a Service objectzEservice_log_path has been deprecated, please pass in a Service objectz?keep_alive has been deprecated, please pass in a Service objectTNzservice cannot be None)Zremote_server_addrbrowser_namevendor_prefix
keep_aliveZignore_proxy)Zcommand_executorr   F)warningswarnDeprecationWarningDEFAULT_PORTportDEFAULT_SERVICE_LOG_PATHDEFAULT_KEEP_ALIVEtyper   create_optionsitemsZset_capabilityZ_ignore_local_proxyAttributeErrorr	   startsuper__init__r   Zservice_url	ExceptionquitZ
_is_remote)selfr   r   r   r   Zservice_argsZdesired_capabilitiesZservice_log_pathr	   r   Z_ignore_proxykeyvalue	__class__ _/var/www/brookimports/venv/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.pyr   %   sX    

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_appg   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getNetworkConditionsr!   r'   r   r$   r$   r%   get_network_conditionsk   s    	z%ChromiumDriver.get_network_conditions)returnc                 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_conditionsv   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_conditions   s    z(ChromiumDriver.delete_network_conditions)namer!   r,   c                 C   s   |  dd|i|d dS )a  
        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setPermissionsr0   )Z
descriptorstateNr'   )r   r0   r!   r$   r$   r%   set_permissions   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'}
        ZexecuteCdpCommand)r3   paramsr!   r'   )r   r3   r4   r$   r$   r%   execute_cdp_cmd   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 )zW
        :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_message)	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   r9   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startDesktopMirroringr:   r'   r;   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startTabMirroringr:   r'   r;   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stopCastingr:   r'   r;   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
        that is started when starting the ChromiumDriver
        N)r   r   r   r	   stopr*   r"   r$   r%   r      s
    zChromiumDriver.quitc                 C   s   | j dkrt S t S d S )Nms)r   EdgeOptionsChromeOptionsr*   r$   r$   r%   r      s    
zChromiumDriver.create_options)__name__
__module____qualname____doc__r   r   r   r   r   r   r)   r+   r.   r/   strr2   dictr6   listr7   r8   r<   r=   r>   r?   r   r   __classcell__r$   r$   r"   r%   r       s,   B				r   )Z!selenium.webdriver.common.optionsr   Z!selenium.webdriver.common.servicer   Zselenium.webdriver.edge.optionsr   rB   Z!selenium.webdriver.chrome.optionsrC   r   Z-selenium.webdriver.chromium.remote_connectionr   Z#selenium.webdriver.remote.webdriverr   ZRemoteWebDriverr   r   r   r   r$   r$   r$   r%   <module>   s   