
    i                     D    d dl mZ d dlmZ d dlmZ  G d d          ZdS )    )Union)WebDriverException)command_builderc                   F    e Zd ZdZd ZddefdZdeeef         ddfdZ	dS )	WebExtensionz9
    BiDi implementation of the webExtension module.
    c                     || _         d S N)conn)selfr
   s     w/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/selenium/webdriver/common/bidi/webextension.py__init__zWebExtension.__init__   s    			    Nreturnc                 t   t          d |||fD                       dk    rt          d          |d|d}n|d|d}n|d|d	}d
|i}	 | j                            t	          d|                    }|S # t
          $ r7}dt          |          v r t          t          |           d          | d}~ww xY w)a  Installs a web extension in the remote end.

        You must provide exactly one of the parameters.

        Parameters:
        -----------
            path: Path to an extension directory
            archive_path: Path to an extension archive file
            base64_value: Base64 encoded string of the extension archive

        Returns:
        -------
            Dict: A dictionary containing the extension ID.
        c              3      K   | ]}|d uV  	d S r	    ).0xs     r   	<genexpr>z'WebExtension.install.<locals>.<genexpr>/   s&      IIq}IIIIIIr      zCExactly one of path, archive_path, or base64_value must be providedNpath)typer   archivePathbase64)r   valueextensionDatazwebExtension.installzMethod not availablez. If you are using Chrome or Edge, add '--enable-unsafe-extension-debugging' and '--remote-debugging-pipe' arguments or set options.enable_webextensions = True)sum
ValueErrorr
   executer   r   str)r   r   archive_pathbase64_valueextension_dataparamsresultes           r   installzWebExtension.install    s    IIt\<&HIIIIIQNNbccc&,d;;NN%&3\JJNN%&.FFN!>2		Y&&7Mv'V'VWWFM! 	 	 	%Q//(1vv i i i   	s   )A6 6
B7 2B22B7extension_id_or_resultc                     t          |t                    r|                    d          }n|}d|i}| j                            t          d|                     dS )a!  Uninstalls a web extension from the remote end.

        Parameters:
        -----------
            extension_id_or_result: Either the extension ID as a string or the result dictionary
                                   from a previous install() call containing the extension ID.
        	extensionzwebExtension.uninstallN)
isinstancedictgetr
   r   r   )r   r(   extension_idr$   s       r   	uninstallzWebExtension.uninstallF   sb     ,d33 	2155kBBLL1L|,	/*BFKKLLLLLr   )NNN)
__name__
__module____qualname____doc__r   r,   r'   r   r    r/   r   r   r   r   r      s           $ $$ $ $ $ $LMc4i0@ MT M M M M M Mr   r   N)typingr   selenium.common.exceptionsr   %selenium.webdriver.common.bidi.commonr   r   r   r   r   <module>r7      sy   $       9 9 9 9 9 9 A A A A A A<M <M <M <M <M <M <M <M <M <Mr   