
    Fth
                         d dl Z 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  e j        e          Zd ZdZdZ G d d	e          Z G d
 de          ZdS )    N)utils)DesiredCapabilities)FirefoxBinary)Command)RemoteConnection c                   Z     e Zd Zd fd	Zd	dZd Zed             Zed             Z xZ	S )
ExtensionConnectionN   c                    || _         || _        |}t          |          }| j        st                      | _        |sd}t	          j                    }|| j         _        | j                                          | j                                          | j        	                    | j         |           d| d| d}t                                          |d           d S )Nz	127.0.0.1)timeoutzhttp://:z/hubT)
keep_alive)profilebinaryintr   r   	free_portportupdate_preferencesadd_extensionlaunch_browsersuper__init__)	selfhostfirefox_profilefirefox_binaryr   HOSTPORT_URL	__class__s	           /var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/selenium/webdriver/firefox/extension_connection.pyr   zExtensionConnection.__init__"   s    &$g,,{ 	*'//DK 	D   '')))""$$$""4<"AAA******$/////    c                     |                      t          j        d|i           |                                 rDt                              d           t          j        d           |                                 Bd S d S )N	sessionIdzwaiting to quit   )executer   QUITis_connectableLOGGERinfotimesleep)r   r%   s     r"   quitzExtensionConnection.quit8   s{    W\K#;<<<!!## 	KK)***JqMMM !!## 	 	 	 	 	r#   c                 Z    |                      t          j        dt          j        i          S )z7Connects to the extension and retrieves the session id.desiredCapabilities)r'   r   NEW_SESSIONr   FIREFOX)r   s    r"   connectzExtensionConnection.connect>   s#    ||G/2GI\Id1efffr#   c                 @    |                      t           d           dS )z4Connects to an running browser and quit immediately.z/extensions/firefox/quitN)_requestr    clss    r"   connect_and_quitz$ExtensionConnection.connect_and_quitB   s%     	66677777r#   c                 B    t          j        | j        j                   dS )z>Tries to connect to the extension but do not retrieve context.N)r   r)   r   r   r6   s    r"   r)   z"ExtensionConnection.is_connectableG   s      	S[-.....r#   )Nr   )N)
__name__
__module____qualname__r   r.   r3   classmethodr8   r)   __classcell__)r!   s   @r"   r
   r
   !   s        0 0 0 0 0 0,   g g g 8 8 [8 / / [/ / / / /r#   r
   c                       e Zd ZdZdS )ExtensionConnectionErrorziAn internal error occurred int the extension.

    Might be caused by bad input or bugs in webdriver
    N)r:   r;   r<   __doc__ r#   r"   r@   r@   M   s         
 	Dr#   r@   )loggingr,   selenium.webdriver.commonr   .selenium.webdriver.common.desired_capabilitiesr   )selenium.webdriver.firefox.firefox_binaryr   !selenium.webdriver.remote.commandr   +selenium.webdriver.remote.remote_connectionr   	getLoggerr:   r*   r   r   r    r
   	Exceptionr@   rB   r#   r"   <module>rK      s   $   + + + + + + N N N N N N C C C C C C 5 5 5 5 5 5 H H H H H H		8	$	$	)/ )/ )/ )/ )/* )/ )/ )/X	 	 	 	 	y 	 	 	 	 	r#   