
    i                     b    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e	      Zy	)
    )ChromiumOptions)ChromiumRemoteConnection)ChromiumService)DriverFinder)LocalWebDriver)Commandc                        e Zd ZdZ	 	 	 ddedededz  dedz  deddf fd	Zd
 Z	d Z
ddZddZdededdfdZdedef fdZdefdZd Zed        Zd ZdedefdZdedefdZdedefdZdedefdZ xZS )ChromiumDriverzGControl the WebDriver instance of ChromiumDriver and drive the browser.Nbrowser_namevendor_prefixoptionsservice
keep_alivereturnc                    |r|n	t               | _        |r|n	t               | _        t	        | j                  | j                        }|j                         r0|j                         | j                  _        d| j                  _        | j                  j                         xs |j                         | j                  _
        | j                  j                          t        | j                  j                  |||| j                  j                        }	 t        | A  || j                         y# t"        $ r | j%                           w xY w)a  Create a new WebDriver instance, start the service, and create new ChromiumDriver instance.

        Args:
            browser_name: Browser name used when matching capabilities.
            vendor_prefix: Company prefix to apply to vendor-specific WebDriver extension commands.
            options: 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   )r   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)	selfr   r   r   r   r   finderexecutor	__class__s	           a/var/www/html/BatchJob/venv/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.pyr   zChromiumDriver.__init__   s    " #*w/@")w/@dllDLL9""$+1+B+B+DDLL(+/DLL( LL113Ov7M7M7O+#||77%'!99
	GhM 	IIK	s   D2 2Ec                 *    | j                  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)   s     r&   
launch_appzChromiumDriver.launch_appG   s     ||K$44    c                 *    | j                  d      d   S )zGets Chromium network emulation settings.

        Returns:
            A dict. For example: {'latency': 4, 'download_throughput': 2, 'upload_throughput': 2}
        getNetworkConditionsvaluer*   r"   s    r&   get_network_conditionsz%ChromiumDriver.get_network_conditionsO   s     ||23G<<r-   c                 ,    | j                  dd|i       y)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   s     r&   set_network_conditionsz%ChromiumDriver.set_network_conditionsW   s      	+.BDV-WXr-   c                 &    | j                  d       y)z+Resets Chromium network emulation settings.deleteNetworkConditionsNr*   r1   s    r&   delete_network_conditionsz(ChromiumDriver.delete_network_conditionsi   s    ./r-   namer0   c                 2    | j                  dd|i|d       y)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")
        setPermissionsr:   )
descriptorstateNr*   )r"   r:   r0   s      r&   set_permissionszChromiumDriver.set_permissionsm   s     	%vtnu'UVr-   cmdcmd_argsc                 $    t         |   ||      S )a  Execute Chrome Devtools Protocol command and get returned result.

        The command and command args should follow chrome devtools protocol domains/commands

        See:
          - 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@   rA   r%   s      r&   rC   zChromiumDriver.execute_cdp_cmdy   s    ( w&sH55r-   c                 *    | j                  d      d   S )z'Get a list of sinks available for Cast.getSinksr0   r*   r1   s    r&   	get_sinkszChromiumDriver.get_sinks   s    ||J'00r-   c                 *    | j                  d      d   S )zCReturns an error message when there is any issue in a Cast session.getIssueMessager0   r*   r1   s    r&   get_issue_messagez ChromiumDriver.get_issue_message   s    ||-.w77r-   c                 F    | j                  t        j                        d   S )zpGets a list of the available log types.

        Example:
        --------
        >>> driver.log_types
        r0   )r+   r   GET_AVAILABLE_LOG_TYPESr1   s    r&   	log_typeszChromiumDriver.log_types   s     ||G;;<WEEr-   c                 L    | j                  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")
        typer0   )r+   r   GET_LOG)r"   log_types     r&   get_logzChromiumDriver.get_log   s#     ||GOOfh-?@IIr-   	sink_namec                 *    | j                  dd|i      S )zSet a specific sink as a Cast session receiver target.

        Args:
            sink_name: Name of the sink to use as the target.
        setSinkToUsesinkNamer*   r"   rR   s     r&   set_sink_to_usezChromiumDriver.set_sink_to_use   s     ||NZ,CDDr-   c                 *    | j                  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.
        startDesktopMirroringrU   r*   rV   s     r&   start_desktop_mirroringz&ChromiumDriver.start_desktop_mirroring   s     ||3j)5LMMr-   c                 *    | j                  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.
        startTabMirroringrU   r*   rV   s     r&   start_tab_mirroringz"ChromiumDriver.start_tab_mirroring   s     ||/*i1HIIr-   c                 *    | j                  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.
        stopCastingrU   r*   rV   s     r&   stop_castingzChromiumDriver.stop_casting   s     ||MJ	+BCCr-   )NNT)r   N)__name__
__module____qualname____doc__strr   r   boolr   r,   r2   r6   r9   r?   dictrC   listrF   rI   propertyrL   rQ   rW   rZ   r]   r`   __classcell__)r%   s   @r&   r
   r
      s&   Q +/*.(( ( !4'	(
 !4'( ( 
(T5=Y$0
WC 
W 
W 
W63 6$ 6,14 18 F FJE E EN N NJS JT JDc Dd Dr-   r
   N)#selenium.webdriver.chromium.optionsr   -selenium.webdriver.chromium.remote_connectionr   #selenium.webdriver.chromium.servicer   'selenium.webdriver.common.driver_finderr   #selenium.webdriver.common.webdriverr   !selenium.webdriver.remote.commandr   r
    r-   r&   <module>rr      s*   $ @ R ? @ > 5sD^ sDr-   