
    gO                         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dS )    N)BinaryIO)Dict)List)Optional)Union)DesiredCapabilities)
ArgOptionsc            	       |    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                     t                                                       d| _        g | _        g | _        i | _        d | _        d S )N )super__init___binary_location_extension_files_extensions_experimental_options_debugger_address)self	__class__s    o/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/selenium/webdriver/chromium/options.pyr   zChromiumOptions.__init__!   sG    %'+-&(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                 f    t          |t                    st          | j                  || _        dS )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.   s5     %%% 	8D67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                 \    t          |t                    st          d          || _        dS )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>   s4     %%% 	A?@@@!&r   c                     dt           dt          fd}g }| j        D ]H}t          |d          5 }|                     ||                     ddd           n# 1 swxY w Y   I|| j        z   S )z;:Returns: A list of encoded extensions that will be loaded.	file_datar   c                 t    t          j        |                                                               d          S )Nzutf-8)base64	b64encodereaddecode)r(   s    r   _decodez+ChromiumOptions.extensions.<locals>._decodeN   s-     #INN$4$455<<WEEEr   rbN)r   r    r   openappendr   )r   r.   encoded_extensions	extensionfs        r   
extensionszChromiumOptions.extensionsJ   s    	Fx 	FC 	F 	F 	F 	F  . 	6 	6Ii&& 6!"))''!**5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 "D$444s   AA	 A	r3   c                 0   |rt           j                            t           j                            |                    }t           j                            |          r| j                            |           dS 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[   s      	9!wrw/A/A)/L/LMMw~~.// E%,,-=>>>>>CDDD7888r   c                 \    |r| j                             |           dS 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   s8      	9##I.....78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         |<   dS )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                    | j         }| j                                        }| j        r|                    | 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     z27799 	7!!$"5666'+|$ 	<'+';N8$!%v  	F040EN,-'TXr   c                 >    t           j                                        S )N)r   CHROMErN   r   s    r   default_capabilitiesz$ChromiumOptions.default_capabilities   s    ")..0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      s       
C5 5 5 5 5 5 % % % % X% &S &T & & & & &(3- & & & X& 	'c 	'd 	' 	' 	' 	' 5DI 5 5 5 X5 9s 9t 9 9 9 9 
9s 
9t 
9 
9 
9 
9 *d * * * X*1C 1c3dSVi>W8X 1]a 1 1 1 1    $ 1d 1 1 1 X1 1 1 1 1r   r   )r*   r8   typingr   r   r   r   r   .selenium.webdriver.common.desired_capabilitiesr   !selenium.webdriver.common.optionsr	   r    r   r   <module>re      s   $  				                               N N N N N N 8 8 8 8 8 8{1 {1 {1 {1 {1j {1 {1 {1 {1 {1r   