
    hg                     f    d dl Z d dlZd dlZd dlmZmZmZ d dlmZ d dl	m
Z
  G d de
          ZdS )    N)ListNoReturnUnion)DesiredCapabilities)
ArgOptionsc            	           e Zd ZdZ fdZedefd            Zej        defd            Zedefd            Z	e	j        defd	            Z	ede
e         fd
            ZdedefdZdedefdZedefd            Zdedeeeee
e         f         fdZedefd            Zej        defd            ZdefdZedefd            Z xZS )ChromiumOptionszgoog:chromeOptionsc                     t          t          |                                            d| _        g | _        g | _        i | _        d | _        d S )N )superr	   __init___binary_location_extension_files_extensions_experimental_options_debugger_address)self	__class__s    \/var/www/fb-scrape/myenv/lib/python3.11/site-packages/selenium/webdriver/chromium/options.pyr   zChromiumOptions.__init__   sM    ot$$--/// " "%'"!%    returnc                     | j         S )zQ
        :Returns: The location of the binary, otherwise an empty string
        r   r   s    r   binary_locationzChromiumOptions.binary_location&   s    
 $$r   valuec                     || _         dS )z
        Allows you to set where the chromium binary lives
        :Args:
         - value: path to the Chromium binary
        Nr   r   r   s     r   r   zChromiumOptions.binary_location-   s     !&r   r   c                     | j         S )zG
        :Returns: The address of the remote devtools instance
        r   r   s    r   debugger_addressz ChromiumOptions.debugger_address6   s    
 %%r   c                     || _         dS )a
  
        Allows 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])
        Nr    r   s     r   r!   z ChromiumOptions.debugger_address=   s     "'r   c                    g }| j         D ]r}t          |d          }|                    t          j        |                                                              d                     |                                 s|| j        z   S )zL
        :Returns: A list of encoded extensions that will be loaded
        rbzUTF-8)	r   openappendbase64	b64encodereaddecodecloser   )r   encoded_extensionsextfile_s       r   
extensionszChromiumOptions.extensionsH   s}    
  ( 	 	CdOOE %%f&6uzz||&D&D&K&KG&T&TUUUKKMMMM!D$444r   	extensionc                 0   |rt           j                            t           j                            |                    }t           j                            |          r| j                            |           dS t          d          t          d          )z
        Adds 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   r&   IOError
ValueError)r   r0   extension_to_adds      r   add_extensionzChromiumOptions.add_extensionX   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          )z
        Adds 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
        r2   N)r   r&   r9   )r   r0   s     r   add_encoded_extensionz%ChromiumOptions.add_encoded_extensioni   s8      	9##I.....7888r   c                     | j         S )zM
        :Returns: A dictionary of experimental options for chromium
        )r   r   s    r   experimental_optionsz$ChromiumOptions.experimental_optionsv   s    
 ))r   namec                     |                                 dk    r+|dk    s|du r!t          j        t          d                     || j        |<   dS )z
        Adds an experimental option which is passed to chromium.

        :Args:
          name: The experimental option name.
          value: The option value.
        w3cfalseFz<Manipulating `w3c` setting can have unintended consequences.N)lowerwarningswarnUserWarningr   )r   r@   r   s      r   add_experimental_optionz'ChromiumOptions.add_experimental_option}   sU     ::<<5  ew&6&6%5..M+&deefff+0"4(((r   c                     d| j         v S )zL
        :Returns: True if the headless argument is set, else False
        
--headless)
_argumentsr   s    r   headlesszChromiumOptions.headless   s    
 t..r   c                     dh}|du r| j                             |           dS t          t          | j                   |z
            | _         dS )z
        Sets the headless argument
        :Args:
          value: boolean value indicating to set the headless option
        rJ   TN)rK   extendlistset)r   r   argss      r   rL   zChromiumOptions.headless   sR     ~D==O""4((((("3t#7#7$#>??DOOOr   c                    | j         }| j                                        }| j        r|                    | j                   | j        |d<   | j        r
| j        |d<   | j        |d<   | j        r
| j        |d<   ||| j	        <   |S )z
        Creates a capabilities with all the options that have been set
        :Returns: A dictionary with everything
        r/   binaryrQ   debuggerAddress)
_capsr?   copymobile_optionsupdater/   r   rK   r!   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   CHROMErV   r   s    r   default_capabilitiesz$ChromiumOptions.default_capabilities   s    ")..000r   )__name__
__module____qualname__rY   r   propertystrr   setterr!   r   r/   r   r;   r=   dictr?   r   intrH   boolrL   r\   r_   __classcell__)r   s   @r   r	   r	      sC       
C& & & & & % % % % X% &S & & & & &s & & & X& 'c ' ' ' ' 5DI 5 5 5 X59s 9x 9 9 9 9"9s 9x 9 9 9 9 *d * * * X*
1C 
1c3dSVi>W8X 
1 
1 
1 
1 /$ / / / X/ _
@d 
@ 
@ 
@ _
@    ( 1d 1 1 1 X1 1 1 1 1r   r	   )r'   r3   rE   typingr   r   r   .selenium.webdriver.common.desired_capabilitiesr   !selenium.webdriver.common.optionsr   r	    r   r   <module>rn      s   $  				  ( ( ( ( ( ( ( ( ( ( N N N N N N 8 8 8 8 8 8X1 X1 X1 X1 X1j X1 X1 X1 X1 X1r   