o
    ѷ6i                     @   s*   d dl mZ d dlmZ G dd dZdS )    )WebDriverException)command_builderc                   @   s>   e Zd ZdZdd ZddefddZdeeB ddfd	d
ZdS )WebExtensionz/BiDi implementation of the webExtension module.c                 C   s
   || _ d S N)conn)selfr    r   p/var/www/hoanhtaovolam_webdjango/env/lib/python3.10/site-packages/selenium/webdriver/common/bidi/webextension.py__init__   s   
zWebExtension.__init__Nreturnc              
   C   s   t dd |||fD dkrtd|durd|d}n|dur&d|d}n	|dur/d	|d
}d|i}z| jtd|}|W S  ty\ } zdt|v rWtt| d| d}~ww )a}  Installs a web extension in the remote end.

        You must provide exactly one of the parameters.

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

        Returns:
            A dictionary containing the extension ID.
        c                 s   s    | ]}|d uV  qd S r   r   ).0xr   r   r	   	<genexpr>*   s    z'WebExtension.install.<locals>.<genexpr>   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er   r   r	   install   s,   
zWebExtension.installextension_id_or_resultc                 C   s8   t |tr|d}n|}d|i}| jtd| dS )zUninstalls a web extension from the remote end.

        Args:
            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   r   r   r	   	uninstallA   s
   
zWebExtension.uninstall)NNN)	__name__
__module____qualname____doc__r
   r$   r    r   r'   r   r   r   r	   r      s
    $r   N)selenium.common.exceptionsr   %selenium.webdriver.common.bidi.commonr   r   r   r   r   r	   <module>   s   