
    8h
                         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y)    N)utils)DesiredCapabilities)FirefoxBinary)Command)RemoteConnection c                   N     e Zd Zd fd	ZddZd Zed        Zed        Z xZ	S )ExtensionConnectionc                    || _         || _        |}t        |      }| j                  st               | _        |sd}t	        j
                         }|| j                   _        | j                   j                          | j                   j                          | j                  j                  | j                   |       d| d| d}t        | -  |d       y )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	           /home/stella.sw7ft.com/public_html/site_rebuilder/venv/lib/python3.12/site-packages/selenium/webdriver/firefox/extension_connection.pyr   zExtensionConnection.__init__"   s    &$g,{{'/DKD  '')""$""4<<"AavT*$/    c                     | j                  t        j                  d|i       | j                         r<t        j                  d       t        j                  d       | j                         r;y y )N	sessionIdzwaiting to quit   )executer   QUITis_connectableLOGGERinfotimesleep)r   r$   s     r!   quitzExtensionConnection.quit8   sK    W\\K#;<!!#KK)*JJqM !!#r"   c                 b    | j                  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\IdId1effr"   c                 4    | j                  t         d       y)z4Connects to an running browser and quit immediately.z/extensions/firefox/quitN)_requestr   clss    r!   connect_and_quitz$ExtensionConnection.connect_and_quitB   s     	v567r"   c                 V    t        j                  | j                  j                         y)z>Tries to connect to the extension but do not retrieve context.N)r   r(   r   r   r5   s    r!   r(   z"ExtensionConnection.is_connectableG   s     	S[[--.r"   )N   )N)
__name__
__module____qualname__r   r-   r2   classmethodr7   r(   __classcell__)r    s   @r!   r
   r
   !   s;    0,g 8 8 / /r"   r
   c                       e Zd ZdZy)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    
 	r"   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      sW   $   + N C 5 H			8	$	)/* )/X	y 	r"   