
    i"                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJr  S S	KJr   " S
 S\5      rg)    N)contextmanager)BytesIO)Optional)DriverFinder)Options)FirefoxRemoteConnection)Service)	WebDriverc            	          ^  \ rS rSrSrSrSr   SS\\   S\\	   S\
S	S4U 4S
 jjjrSU 4S jjrSS jr\S 5       rSS	\4S jjrSS jrS	\
4S jrS	\
4S jrS	\4S jrS	\4S jrS rS rS rSrU =r$ )r
       z=Controls the GeckoDriver and allows you to drive the browser.chromecontentNoptionsservice
keep_alivereturnc                 X  > U(       a  UO	[        5       U l        U(       a  UO	[        5       n[        U R                  U5      nUR	                  5       (       a  UR	                  5       Ul        SUl        U R                  R                  5       =(       d    UR                  5       U R                  l	        U R                  R                  5         [        U R                  R                  UUR                  S9n [        TU ]=  XQS9  SU l        g! [          a    U R#                  5         e f = f)af  Creates a new instance of the Firefox driver. Starts the service and
then creates new instance of Firefox driver.

Args:
    options: Instance of ``options.Options``.
    service: (Optional) service instance for managing the starting and stopping of the driver.
    keep_alive: Whether to configure remote_connection.RemoteConnection to use HTTP keep-alive.
N)remote_server_addrr   ignore_proxy)command_executorr   F)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
_is_remote)selfr   r   r   finderexecutor	__class__s         QC:\des-py\RoboSAPF\venv\Lib\site-packages\selenium\webdriver\firefox\webdriver.pyr!   WebDriver.__init__&   s     #*wwy$'')dllG4""$$&,&=&=&?G#&*G# LL113Ov7M7M7O*#||77! 44
	GhH
  	  	IIK	s   8D D)c                    >  [         TU ]  5         U R                  R	                  5         g! [         a     N'f = f! U R                  R	                  5         f = f)z=Closes the browser and shuts down the GeckoDriver executable.N)r    r#   r"   r   stop)r%   r(   s    r)   r#   WebDriver.quitN   sJ    	 GLN
 LL	  		 LLs   , 
9< 9< Ac                 ,    U R                  SSU05        g)zSets 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%   r0   s     r)   set_contextWebDriver.set_contextX   s     	]Y$89    c              #      #    U R                  S5      R                  S5      nU R                  U5         Sv   U R                  U5        g! U R                  U5        f = f7f)a  Sets 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)r2   popr3   )r%   r0   initial_contexts      r)   r0   WebDriver.context`   sR      ,,}599'B!	._-D_-s   2A!A A!AA!c           	      <   [         R                  R                  U5      (       a  [        5       n[         R                  R	                  U5      n[        U5      S-   n[        R                  " US[        R                  SS9 n[         R                  " U5       HB  u  pgnU H6  n	[         R                  R                  Xi5      n
UR                  XUS 5        M8     MD     SSS5        [        R                  " UR                  5       5      R                  S5      nOH[!        US5       n[        R                  " UR#                  5       5      R                  S5      nSSS5        WUS.nU R%                  S	U5      S
   $ ! , (       d  f       N= f! , (       d  f       N9= f)au  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_ADDONr8   )osr   isdirr   normpathlenzipfileZipFileZIP_DEFLATEDwalkjoinwritebase64	b64encodegetvaluedecodeopenreadr2   )r%   r   rB   fp	path_rootzippedbase_filesfylefilenamerA   filepayloads                 r)   install_addonWebDriver.install_addonv   s0   " 77==B77##D)DD	AIS'*>*>RWX\b&(ggdmNDU %#%77<<#;X	
/CD !& '4 Y
 $$R[[]3::7CEdD!T((5<<WE " "	:||OW5g>> YX "!s   AE<&4F<
F

Fc                 ,    U R                  SSU05        g)zUninstalls Firefox addon using its identifier.

Args:
    identifier: The addon identifier to uninstall.

Example:
    driver.uninstall_addon("addon@foo.com")
UNINSTALL_ADDONidNr1   )r%   
identifiers     r)   uninstall_addonWebDriver.uninstall_addon   s     	&z(:;r5   c                 B   UR                  5       R                  S5      (       d  [        R                  " S[        5        U R                  5       n [        US5       nUR                  U5        SSS5        Ag! , (       d  f       N= f! [         a     Agf = f! Af = f)an  Saves a full document screenshot of the current window to a PNG
image file. Returns False if there is any IOError, else returns True.
Use full paths in your filename.

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

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_pngrR   rM   OSError)r%   r[   pngfs       r)    get_full_page_screenshot_as_file*WebDriver.get_full_page_screenshot_as_file   s     ~~((00MMp 224	h% &
  &% 		 sH   B
 A9/B
 9
BB
 B B
 

BB BB Bc                 $    U R                  U5      $ )ag  Saves a full document screenshot of the current window to a PNG
image file. Returns False if there is any IOError, else returns True.
Use full paths in your filename.

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

Example:
    driver.save_full_page_screenshot("/Screenshots/foo.png")
)rq   )r%   r[   s     r)   save_full_page_screenshot#WebDriver.save_full_page_screenshot   s     44X>>r5   c                 h    [         R                  " U R                  5       R                  S5      5      $ )zGets the full document screenshot of the current window as a binary
data.

Returns:
    Binary data of the screenshot.

Example:
    driver.get_full_page_screenshot_as_png()
ascii)rN   	b64decode"get_full_page_screenshot_as_base64encoder%   s    r)   rm   )WebDriver.get_full_page_screenshot_as_png   s*      G G I P PQX YZZr5   c                 *    U R                  S5      S   $ )zGets the full document screenshot of the current window as a base64
encoded string which is useful in embedded images in HTML.

Returns:
    Base64 encoded string of the screenshot.

Example:
    driver.get_full_page_screenshot_as_base64()
FULL_PAGE_SCREENSHOTr8   r1   r{   s    r)   ry   ,WebDriver.get_full_page_screenshot_as_base64   s     ||23G<<r5   c                     [         e)zBDownload file functionality is not implemented for Firefox driver.NotImplementedErrorr%   argskwargss      r)   download_fileWebDriver.download_file       !!r5   c                     [         e)zKGet downloadable files functionality is not implemented for Firefox driver.r   r   s      r)   get_downloadable_files WebDriver.get_downloadable_files   r   r5   c                     [         e)zNDelete downloadable files functionality is not implemented for Firefox driver.r   r   s      r)   delete_downloadable_files#WebDriver.delete_downloadable_files   r   r5   )r$   r   )NNT)r   N)F)__name__
__module____qualname____firstlineno____doc__CONTEXT_CHROMECONTEXT_CONTENTr   r   r	   boolr!   r#   r3   r   r0   strr^   rd   rq   rt   bytesrm   ry   r   r   r   __static_attributes____classcell__)r(   s   @r)   r
   r
       s    GNO &*%)	& '"&  '"&  	& 
 
&  & P : . .*"?c "?H	<D 6?T ?
[ 
[
=C 
=""" "r5   r
   )rN   rD   rj   rH   
contextlibr   ior   typingr   'selenium.webdriver.common.driver_finderr   "selenium.webdriver.firefox.optionsr   ,selenium.webdriver.firefox.remote_connectionr   "selenium.webdriver.firefox.servicer	   #selenium.webdriver.remote.webdriverr
   RemoteWebDriver r5   r)   <module>r      s9   "  	   %   @ 6 P 6 LP" P"r5   