
    Eg$                     ~    d dl 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 d ZdZdZ G d de          ZdS )	    N)Options)ChromiumRemoteConnection)BaseOptions)Service)	WebDriverc                        e Zd ZdZedddedef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defdZ xZS )ChromiumDriverzZControls the WebDriver instance of ChromiumDriver and allows you to
    drive the browser.Noptionsservicereturnc
           	      ^   |rt          j        dt          d           |t          k    rt          j        dt          d           || _        |t
          k    rt          j        dt          d           |	t          k    r0t          |           k    rt          j        dt          d           nd}	|| _        d}
|s| 	                                }|r0|
                                D ]\  }}|                    ||           |j        r|j        }
|st          d	          || _        | j                                         	 t!                                          t%          | j        j        |||	|

          |           n## t(          $ r |                                   w xY w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)remote_server_addrbrowser_namevendor_prefix
keep_aliveignore_proxy)command_executorr
   F)warningswarnDeprecationWarningDEFAULT_PORTportDEFAULT_SERVICE_LOG_PATHDEFAULT_KEEP_ALIVEtyper   create_optionsitemsset_capability_ignore_local_proxyAttributeErrorr   startsuper__init__r   service_url	Exceptionquit
_is_remote)selfr   r   r   r
   service_argsdesired_capabilitiesservice_log_pathr   r   _ignore_proxykeyvalue	__class__s                Z/var/www/sysmax/venv/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.pyr%   zChromiumDriver.__init__$   s   4   	M["   
 <MUWivwxxxx	777MW"   
 +++T

i0G0GMQSers     J* 	,))++G 	3288:: 3 3
U&&sE2222& 	8#7M 	; !9:::	GG!9'+|'?!-"/)!." " "    	 	 	 	  	 	 	IIKKK	  s   ?F  F#c                 2    |                      dd|i          S )z&Launches Chromium app specified by id.	launchAppidexecute)r*   r5   s     r2   
launch_appzChromiumDriver.launch_appw   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}
        getNetworkConditionsr0   r6   r*   s    r2   get_network_conditionsz%ChromiumDriver.get_network_conditions{   s     ||233G<<r9   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_conditionsNr6   )r*   r@   s     r2   set_network_conditionsz%ChromiumDriver.set_network_conditions   s&    " 	+.BDV-WXXXXXr9   c                 0    |                      d           dS )z+Resets Chromium network emulation settings.deleteNetworkConditionsNr6   r<   s    r2   delete_network_conditionsz(ChromiumDriver.delete_network_conditions   s    ./////r9   namer0   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')
        setPermissionsrE   )
descriptorstateNr6   )r*   rE   r0   s      r2   set_permissionszChromiumDriver.set_permissions   s+     	%vtnu'U'UVVVVVr9   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)rK   paramsr0   r6   )r*   rK   rL   s      r2   execute_cdp_cmdzChromiumDriver.execute_cdp_cmd   s'    " ||/1Q1QRRSZ[[r9   c                 8    |                      d          d         S )z?
        :Returns: A list of sinks available for Cast.
        getSinksr0   r6   r<   s    r2   	get_sinkszChromiumDriver.get_sinks   s     ||J''00r9   c                 8    |                      d          d         S )zW
        :Returns: An error message when there is any issue in a Cast session.
        getIssueMessager0   r6   r<   s    r2   get_issue_messagez ChromiumDriver.get_issue_message   s     ||-..w77r9   	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sinkNamer6   r*   rW   s     r2   set_sink_to_usezChromiumDriver.set_sink_to_use   s     ||NZ,CDDDr9   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.
        startDesktopMirroringrZ   r6   r[   s     r2   start_desktop_mirroringz&ChromiumDriver.start_desktop_mirroring   s     ||3j)5LMMMr9   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.
        startTabMirroringrZ   r6   r[   s     r2   start_tab_mirroringz"ChromiumDriver.start_tab_mirroring   s     ||/*i1HIIIr9   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.
        stopCastingrZ   r6   r[   s     r2   stop_castingzChromiumDriver.stop_casting   s     ||MJ	+BCCCr9   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*   r1   s    r2   r(   zChromiumDriver.quit   sq    	 GGLLNNNN 	 	 	D	 LDLs!    $ A 
1A 1A A*c                 P    | j         dk    rt                      nt                      S )Nms)r   EdgeOptionsChromeOptionsr<   s    r2   r   zChromiumDriver.create_options   s!     $ 2d : :{}}}Or9   )r   N)__name__
__module____qualname____doc__r   r   r   r   r   r%   r8   r=   rA   rD   strrJ   dictrP   listrS   rV   r\   r_   rb   re   r(   r   __classcell__)r1   s   @r2   r	   r	       s:         #!1%Q  Q 
 Q  Q  
Q  Q  Q  Q  Q  Q f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	  	  	  	  	  	 P P P P P P P P Pr9   r	   )r   !selenium.webdriver.chrome.optionsr   rk   -selenium.webdriver.chromium.remote_connectionr   !selenium.webdriver.common.optionsr   !selenium.webdriver.common.servicer   selenium.webdriver.edge.optionsrj   #selenium.webdriver.remote.webdriverr   RemoteWebDriverr   r   r   r	    r9   r2   <module>r|      s   $  F F F F F F R R R R R R 9 9 9 9 9 9 5 5 5 5 5 5 B B B B B B L L L L L L  UP UP UP UP UP_ UP UP UP UP UPr9   