
    Fthq                     ^    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dS )	    )ChromiumRemoteConnection)DriverFinder)
ArgOptions)Service)	WebDriverc                        e Zd ZdZ	 dde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dZdef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d fdZ xZS )ChromiumDriverzZControls the WebDriver instance of ChromiumDriver and allows you to
    drive the browser.ToptionsservicereturnNc           	      ~   || _         || _        t          j        | j        |          | j        _        | j                                         	 t                                          t          | j        j	        ||||j
                  |           n## t          $ r |                                   w xY 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__s         y/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.pyr   zChromiumDriver.__init__   s    $ +(1$,HH	GG!9'+|'?!-"/)!(!<" " "    	 	 	 	  	 	 	IIKKK	  s   AB  B3c                 2    |                      dd|i          S )z&Launches Chromium app specified by id.	launchAppidexecute)r   r#   s     r    
launch_appzChromiumDriver.launch_appG   s    ||K$444    c                 8    |                      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   s    r    get_network_conditionsz%ChromiumDriver.get_network_conditionsK   s     ||233G<<r'   c                 6    |                      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/   s     r    set_network_conditionsz%ChromiumDriver.set_network_conditionsT   s&    " 	+.BDV-WXXXXXr'   c                 0    |                      d           dS )z+Resets Chromium network emulation settings.deleteNetworkConditionsNr$   r+   s    r    delete_network_conditionsz(ChromiumDriver.delete_network_conditionsg   s    ./////r'   namer*   c                 <    |                      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')
        setPermissionsr4   )
descriptorstateNr$   )r   r4   r*   s      r    set_permissionszChromiumDriver.set_permissionsk   s+     	%vtnu'U'UVVVVVr'   cmdcmd_argsc                 @    |                      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)r:   paramsr*   r$   )r   r:   r;   s      r    execute_cdp_cmdzChromiumDriver.execute_cdp_cmdy   s'    $ ||/1Q1QRRSZ[[r'   c                 8    |                      d          d         S )z-:Returns: A list of sinks available for Cast.getSinksr*   r$   r+   s    r    	get_sinkszChromiumDriver.get_sinks   s    ||J''00r'   c                 8    |                      d          d         S )zM:Returns: An error message when there is any issue in a Cast
        session.getIssueMessager*   r$   r+   s    r    get_issue_messagez ChromiumDriver.get_issue_message   s     ||-..w77r'   	sink_namec                 2    |                      dd|i          S )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   rF   s     r    set_sink_to_usezChromiumDriver.set_sink_to_use   s     ||NZ,CDDDr'   c                 2    |                      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.
        startDesktopMirroringrI   r$   rJ   s     r    start_desktop_mirroringz&ChromiumDriver.start_desktop_mirroring   s     ||3j)5LMMMr'   c                 2    |                      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.
        startTabMirroringrI   r$   rJ   s     r    start_tab_mirroringz"ChromiumDriver.start_tab_mirroring   s     ||/*i1HIIIr'   c                 2    |                      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.
        stopCastingrI   r$   rJ   s     r    stop_castingzChromiumDriver.stop_casting   s     ||MJ	+BCCCr'   c                     	 t                                                       n# t          $ r Y nw xY w| j                                         dS # | j                                         w xY w)zyCloses the browser and shuts down the ChromiumDriver executable that
        is started when starting the ChromiumDriver.N)r   r   r   r   stop)r   r   s    r    r   zChromiumDriver.quit   sq    	 GGLLNNNN 	 	 	D	 LDLs!    $ A 
1A 1A A*)T)r   N)__name__
__module____qualname____doc__r   r   r   r&   r,   r0   r3   strr9   dictr?   listrB   rE   rK   rN   rQ   rT   r   __classcell__)r   s   @r    r	   r	      s         (  (  	( 
 (  
(  (  (  (  (  ( T5 5 5= = =Y Y Y Y&0 0 0 0WC W W W W W W\3 \$ \ \ \ \(14 1 1 1 18 8 8
E E E E E EN N N N N NJS JT J J J JDc Dd D D D D	  	  	  	  	  	  	  	  	  	 r'   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    <module>rf      s   $ S R R R R R @ @ @ @ @ @ 8 8 8 8 8 8 5 5 5 5 5 5 L L L L L Lg  g  g  g  g _ g  g  g  g  g r'   