
    ,hO                     ~    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)BinaryIO)Dict)List)Optional)Union)DesiredCapabilities)
ArgOptionsc            	       N    e Zd ZdZd fdZedefd       Zej                  deddfd       Zede	e   fd       Z
e
j                  deddfd	       Z
edee   fd
       ZdeddfdZdeddfdZedefd       Zdedeeeeee   f   ddfdZdefdZedefd       Z xZS )ChromiumOptionszgoog:chromeOptionsreturnNc                 h    t         |           d| _        g | _        g | _        i | _        d | _        y )N )super__init___binary_location_extension_files_extensions_experimental_options_debugger_address)self	__class__s    e/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/selenium/webdriver/chromium/options.pyr   zChromiumOptions.__init__!   s6    %'+-&(RT"04    c                     | j                   S )z@:Returns: The location of the binary, otherwise an empty string.)r   r   s    r   binary_locationzChromiumOptions.binary_location)   s     $$$r   valuec                 \    t        |t              st        | j                        || _        y)zyAllows you to set where the chromium binary lives.

        :Args:
         - value: path to the Chromium binary
        N)
isinstancestr	TypeErrorBINARY_LOCATION_ERRORr   r   r   s     r   r   zChromiumOptions.binary_location.   s'     %%D6677 %r   c                     | j                   S )z6:Returns: The address of the remote devtools instance.)r   r   s    r   debugger_addressz ChromiumOptions.debugger_address9   s     %%%r   c                 H    t        |t              st        d      || _        y)zAllows you to set the address of the remote devtools instance that
        the ChromeDriver instance will try to connect to during an active wait.

        :Args:
         - value: address of remote devtools instance if any (hostname[:port])
        z!Debugger Address must be a stringN)r   r    r!   r   r#   s     r   r%   z ChromiumOptions.debugger_address>   s"     %%?@@!&r   c                     dt         dt        fd}g }| j                  D ].  }t        |d      5 }|j	                   ||             ddd       0 || j
                  z   S # 1 sw Y   IxY w)z;:Returns: A list of encoded extensions that will be loaded.	file_datar   c                 f    t        j                  | j                               j                  d      S )Nzutf-8)base64	b64encodereaddecode)r(   s    r   _decodez+ChromiumOptions.extensions.<locals>._decodeN   s'     ##INN$45<<WEEr   rbN)r   r    r   openappendr   )r   r.   encoded_extensions	extensionfs        r   
extensionszChromiumOptions.extensionsJ   s    	Fx 	FC 	F  .. 	6Ii& 6!"))'!*56 6	6 "D$4$4446 6s   AA(	r3   c                     |rt         j                  j                  t         j                  j                  |            }t         j                  j	                  |      r| j
                  j                  |       yt        d      t        d      )zAdds the path to the extension to a list that will be used to
        extract it to the ChromeDriver.

        :Args:
         - extension: path to the \*.crx file
        z#Path to the extension doesn't existargument can not be nullN)	ospathabspath
expanduserexistsr   r1   OSError
ValueError)r   r3   extension_to_adds      r   add_extensionzChromiumOptions.add_extension[   sg     !wwrww/A/A)/LMww~~./%%,,-=>CDD788r   c                 T    |r| j                   j                  |       yt        d      )zAdds Base64 encoded string with extension data to a list that will
        be used to extract it to the ChromeDriver.

        :Args:
         - extension: Base64 encoded string with extension data
        r7   N)r   r1   r>   )r   r3   s     r   add_encoded_extensionz%ChromiumOptions.add_encoded_extensionk   s'     ##I.788r   c                     | j                   S )z<:Returns: A dictionary of experimental options for chromium.r   r   s    r   experimental_optionsz$ChromiumOptions.experimental_optionsw   s     )))r   namec                 "    || j                   |<   y)zAdds an experimental option which is passed to chromium.

        :Args:
          name: The experimental option name.
          value: The option value.
        NrD   )r   rF   r   s      r   add_experimental_optionz'ChromiumOptions.add_experimental_option|   s     ,1""4(r   c                 f   | j                   }| j                  j                         }| j                  r|j	                  | j                         | j
                  |d<   | j                  r| j                  |d<   | j                  |d<   | j                  r| j                  |d<   ||| j                  <   |S )znCreates a capabilities with all the options that have been set
        :Returns: A dictionary with everything.r5   binaryargsdebuggerAddress)
_capsrE   copymobile_optionsupdater5   r   
_argumentsr%   KEY)r   capschrome_optionss      r   to_capabilitieszChromiumOptions.to_capabilities   s     zz22779!!$"5"56'+|$'+';';N8$!%v  040E0EN,-'TXXr   c                 >    t         j                  j                         S )N)r   CHROMErN   r   s    r   default_capabilitiesz$ChromiumOptions.default_capabilities   s    "))..00r   )r   N)__name__
__module____qualname__rR   r   propertyr    r   setterr   r%   r   r5   r@   rB   dictrE   r   intrH   rU   rX   __classcell__)r   s   @r   r   r      sL   
C5 % % % &S &T & & &(3- & & 	'c 	'd 	' 	' 5DI 5 5 9s 9t 9 
9s 
9t 
9 *d * *1C 1c3dSVi>W8X 1]a 1 $ 1d 1 1r   r   )r*   r8   typingr   r   r   r   r   .selenium.webdriver.common.desired_capabilitiesr   !selenium.webdriver.common.optionsr	   r    r   r   <module>re      s0   $  	      N 8{1j {1r   