Ë
    cQbj‘  ã                   óŽ   — d dl Z d dlZ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 d dlmZ d dlmZ  G d	„ d
e«      Zy)é    N)Úcontextmanager)ÚBytesIO)ÚDriverFinder)ÚLocalWebDriver)ÚOptions)ÚFirefoxRemoteConnection)ÚServicec            	       ó®   ‡ — e Zd ZdZdZdZ	 	 	 ddedz  dedz  deddfˆ fd	„Z	dd
„Z
ed„ «       Zddefd„Zdd„Zdefd„Zdefd„Zdefd„Zdefd„Zˆ xZS )Ú	WebDriverz=Controls the GeckoDriver and allows you to drive the browser.ÚchromeÚcontentNÚoptionsÚserviceÚ
keep_aliveÚreturnc                 óœ  •— |r|n	t        «       | _        |r|n	t        «       | _        t	        | j                  | j                  «      }|j                  «       r0|j                  «       | j                  _        d| j                  _        | j                  j                  «       xs |j                  «       | j                  _
        | j                  j                  «        t        | j                  j                  || j                  j                  ¬«      }	 t        ‰| �A  || j                  ¬«       y# t"        $ r | j%                  «        ‚ w xY w)a^  Create a new instance of the Firefox driver, start the service, and create new instance.

        Args:
            options: Instance of Options.
            service: Service object for handling the browser driver if you need to pass extra details.
            keep_alive: Whether to configure FirefoxRemoteConnection to use HTTP keep-alive.
        N)Úremote_server_addrr   Úignore_proxy)Úcommand_executorr   )r	   r   r   r   r   Úget_browser_pathÚbinary_locationÚbrowser_versionÚenv_pathÚget_driver_pathÚpathÚstartr   Úservice_urlÚ_ignore_local_proxyÚsuperÚ__init__Ú	ExceptionÚquit)Úselfr   r   r   ÚfinderÚexecutorÚ	__class__s         €úW/var/www/html/venv/lib/python3.12/site-packages/selenium/webdriver/firefox/webdriver.pyr    zWebDriver.__init__&   sô   ø€ ñ #*‘w¬w«yˆŒÙ")‘w¬w«yˆŒä˜dŸl™l¨D¯L©LÓ9ˆØ×"Ñ"Ô$Ø+1×+BÑ+BÓ+DˆD�L‰LÔ(Ø+/ˆD�L‰LÔ(à ŸL™L×1Ñ1Ó3ÒO°v×7MÑ7MÓ7Oˆ�‰ÔØ�‰×ÑÔä*Ø#Ÿ|™|×7Ñ7Ø!ØŸ™×9Ñ9ô
ˆð	Ü‰GÑ¨hÀÇÁÐÕMøÜò 	Ø�I‰IŒKØð	ús   ÄD0 Ä0Ec                 ó,   — | j                  dd|i«       y)z¨Sets the context that Selenium commands are running in.

        Args:
            context: Context to set, should be one of CONTEXT_CHROME or CONTEXT_CONTENT.
        ÚSET_CONTEXTÚcontextN©Úexecute)r#   r*   s     r'   Úset_contextzWebDriver.set_contextJ   s   € ð 	�‰�] Y°Ð$8Õ9ó    c              #   óÆ   K  — | j                  d«      j                  d«      }| j                  |«       	 d–— | j                  |«       y# | j                  |«       w xY w­w)aç  Set the context that Selenium commands are running in using a `with` statement.

        The state of the context on the server is saved before entering the block,
        and restored upon exiting it.

        Args:
            context: Context, may be one of the class properties
                `CONTEXT_CHROME` or `CONTEXT_CONTENT`.

        Example:
            with selenium.context(selenium.CONTEXT_CHROME):
                # chrome scope
                ... do stuff ...
        ÚGET_CONTEXTÚvalueN)r,   Úpopr-   )r#   r*   Úinitial_contexts      r'   r*   zWebDriver.contextR   sS   è ø€ ð  Ÿ,™, }Ó5×9Ñ9¸'ÓBˆØ×Ñ˜Ô!ð	.Ûà×Ñ˜_Õ-øˆD×Ñ˜_Õ-üs   ‚2A!µA ¹A!ÁAÁA!c           	      ó  — t         j                  j                  |«      rõt        «       }t         j                  j	                  |«      }t        |«      dz   }t        j                  |dt        j                  d¬«      5 }t        j                  |«      D ]B  \  }}}|D ]7  }	t         j                  j                  ||	«      }
|j                  |
|
|d «       Œ9 ŒD 	 ddd«       t        j                  |j                  «       «      j                  d«      }nGt!        |d«      5 }t        j                  |j#                  «       «      j                  d«      }ddd«       |dœ}| j%                  d	|«      d
   S # 1 sw Y   Œ�xY w# 1 sw Y   Œ/xY w)aÅ  Installs Firefox addon.

        Returns identifier of installed addon. This identifier can later
        be used to uninstall addon.

        Args:
            path: Absolute path to the addon that will be installed.
            temporary: Allows you to load browser extensions temporarily during a session.

        Returns:
            Identifier of installed addon.

        Example:
            driver.install_addon("/path/to/firebug.xpi")
        é   ÚwF)Ústrict_timestampsNzUTF-8Úrb)ÚaddonÚ	temporaryÚINSTALL_ADDONr1   )Úosr   Úisdirr   ÚnormpathÚlenÚzipfileÚZipFileÚZIP_DEFLATEDÚwalkÚjoinÚwriteÚbase64Ú	b64encodeÚgetvalueÚdecodeÚopenÚreadr,   )r#   r   r:   ÚfpÚ	path_rootÚzippedÚbaseÚ_ÚfilesÚfyleÚfilenamer9   ÚfileÚpayloads                 r'   Úinstall_addonzWebDriver.install_addoni   sU  € ô  �7‰7�=‰=˜ÔÜ“ˆBä—7‘7×#Ñ# DÓ)ˆDä˜D›	 A™ˆIÜ—‘  S¬'×*>Ñ*>ÐRWÔXð EÐ\bÜ&(§g¡g¨d£mò E‘N�D˜!˜UØ %ò E˜Ü#%§7¡7§<¡<°°dÓ#;˜ØŸ™ X¨x¸	¸
Ð/CÕDñEñE÷Eô
 ×$Ñ$ R§[¡[£]Ó3×:Ñ:¸7ÓC‰Eä�d˜DÓ!ð F TÜ×(Ñ(¨¯©«Ó5×<Ñ<¸WÓE�÷Fð "°	Ñ:ˆØ�|‰|˜O¨WÓ5°gÑ>Ð>÷Eð Eú÷Fð Fús   Á>AE6Ä!3FÅ6E?ÆFc                 ó,   — | j                  dd|i«       y)zÇUninstalls Firefox addon using its identifier.

        Args:
            identifier: The addon identifier to uninstall.

        Example:
            driver.uninstall_addon("addon@foo.com")
        ÚUNINSTALL_ADDONÚidNr+   )r#   Ú
identifiers     r'   Úuninstall_addonzWebDriver.uninstall_addonŒ   s   € ð 	�‰Ð&¨¨zÐ(:Õ;r.   c                 ó*  — |j                  «       j                  d«      st        j                  dt        «       | j                  «       }	 t        |d«      5 }|j                  |«       ddd«       ~y# 1 sw Y   ŒxY w# t        $ r Y ~yw xY w# ~w xY w)a³  Save a full document screenshot of the current window to a PNG image file.

        Args:
            filename: The full path you wish to save your screenshot to. This
                should end with a `.png` extension.

        Returns:
            False if there is any IOError, else returns True. Use full paths in your filename.

        Example:
            driver.get_full_page_screenshot_as_file("/Screenshots/foo.png")
        z.pngz^name used for saved screenshot does not match file type. It should end with a `.png` extensionÚwbNFT)	ÚlowerÚendswithÚwarningsÚwarnÚUserWarningÚget_full_page_screenshot_as_pngrJ   rE   ÚOSError)r#   rS   ÚpngÚfs       r'   Ú get_full_page_screenshot_as_filez*WebDriver.get_full_page_screenshot_as_file—   sŽ   € ð �~‰~Ó×(Ñ(¨Ô0Ü�M‰MØpÜôð ×2Ñ2Ó4ˆð	Ü�h Ó%ð ¨Ø—‘˜”÷ð
 Ø÷ð ûäò 	Øáð	ûñ ús<   ÁA? ÁA3Á)A? Á3A<Á8A? Á?	BÂB ÂBÂB ÂBc                 ó$   — | j                  |«      S )a¬  Save a full document screenshot of the current window to a PNG image file.

        Args:
            filename: The full path you wish to save your screenshot to. This
                should end with a `.png` extension.

        Returns:
            False if there is any IOError, else returns True. Use full paths in your filename.

        Example:
            driver.save_full_page_screenshot("/Screenshots/foo.png")
        )rg   )r#   rS   s     r'   Úsave_full_page_screenshotz#WebDriver.save_full_page_screenshot³   s   € ð ×4Ñ4°XÓ>Ð>r.   c                 óf   — t        j                  | j                  «       j                  d«      «      S )zÓGet the full document screenshot of the current window as binary data.

        Returns:
            Binary data of the screenshot.

        Example:
            driver.get_full_page_screenshot_as_png()
        Úascii)rF   Ú	b64decodeÚ"get_full_page_screenshot_as_base64Úencode©r#   s    r'   rc   z)WebDriver.get_full_page_screenshot_as_pngÂ   s*   € ô ×Ñ × GÑ GÓ I× PÑ PÐQXÓ YÓZÐZr.   c                 ó*   — | j                  d«      d   S )zìGet the full document screenshot of the current window as a base64-encoded string.

        Returns:
            Base64 encoded string of the screenshot.

        Example:
            driver.get_full_page_screenshot_as_base64()
        ÚFULL_PAGE_SCREENSHOTr1   r+   ro   s    r'   rm   z,WebDriver.get_full_page_screenshot_as_base64Í   s   € ð �|‰|Ð2Ó3°GÑ<Ð<r.   )NNT)r   N)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚCONTEXT_CHROMEÚCONTEXT_CONTENTr   r	   Úboolr    r-   r   r*   ÚstrrV   r[   rg   ri   Úbytesrc   rm   Ú__classcell__)r&   s   @r'   r   r       s¬   ø„ ÙGà€NØ€Oð #'Ø"&Øñ	"à˜4‘ð"ð ˜4‘ð"ð ð	"ð
 
õ"óH:ð ñ.ó ð.ñ,!?°có !?óF	<ð¸Dó ð8?°Tó ?ð	[°ó 	[ð	=°C÷ 	=r.   r   )rF   r<   r`   r@   Ú
contextlibr   Úior   Ú'selenium.webdriver.common.driver_finderr   Ú#selenium.webdriver.common.webdriverr   Ú"selenium.webdriver.firefox.optionsr   Ú,selenium.webdriver.firefox.remote_connectionr   Ú"selenium.webdriver.firefox.servicer	   r   © r.   r'   ú<module>r„      s6   ðó$ Û 	Û Û Ý %Ý å @Ý >Ý 6Ý PÝ 6ôv=�õ v=r.   