o
    "{gO                     @   sx   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
 d
eZdS )    N)BinaryIO)Dict)List)Optional)Union)DesiredCapabilities)
ArgOptionsc                	       s  e Zd ZdZd fddZedefddZejdeddfd	dZede	e fd
dZ
e
jdeddfddZ
edee fddZdeddfddZdeddfddZedefddZdedeeeeee f ddfddZdefddZedefddZ  ZS )ChromiumOptionszgoog:chromeOptionsreturnNc                    s,   t    d| _g | _g | _i | _d | _d S )N )super__init___binary_location_extension_files_extensions_experimental_options_debugger_addressself	__class__ /var/www/bot.gig.net.ua/public_html/telegram/P1/HellBot/venv/lib/python3.10/site-packages/selenium/webdriver/chromium/options.pyr   !   s   

zChromiumOptions.__init__c                 C      | j S )z@:Returns: The location of the binary, otherwise an empty string.)r   r   r   r   r   binary_location)      zChromiumOptions.binary_locationvaluec                 C   s   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   r   r   r   r   .   s   


c                 C   r   )z6:Returns: The address of the remote devtools instance.)r   r   r   r   r   debugger_address9   r   z ChromiumOptions.debugger_addressc                 C   s   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!   r   r   r   r"   >   s   

c              	   C   sd   dt dtfdd}g }| jD ]}t|d}||| W d   n1 s'w   Y  q|| j S )z;:Returns: A list of encoded extensions that will be loaded.	file_datar
   c                 S   s   t |  dS )Nzutf-8)base64	b64encodereaddecode)r#   r   r   r   _decodeN   s   z+ChromiumOptions.extensions.<locals>._decoderbN)r   r   r   openappendr   )r   r(   encoded_extensions	extensionfr   r   r   
extensionsJ   s   

zChromiumOptions.extensionsr-   c                 C   sD   |rt 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   r+   OSError
ValueError)r   r-   extension_to_addr   r   r   add_extension[   s   zChromiumOptions.add_extensionc                 C   s   |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
        r0   N)r   r+   r7   )r   r-   r   r   r   add_encoded_extensionk   s   z%ChromiumOptions.add_encoded_extensionc                 C   r   )z<:Returns: A dictionary of experimental options for chromium.r   r   r   r   r   experimental_optionsw   r   z$ChromiumOptions.experimental_optionsnamec                 C   s   || j |< dS )zAdds an experimental option which is passed to chromium.

        :Args:
          name: The experimental option name.
          value: The option value.
        Nr;   )r   r=   r   r   r   r   add_experimental_option|   s   z'ChromiumOptions.add_experimental_optionc                 C   sd   | 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.r/   binaryargsdebuggerAddress)
_capsr<   copymobile_optionsupdater/   r   
_argumentsr"   KEY)r   capschrome_optionsr   r   r   to_capabilities   s   





zChromiumOptions.to_capabilitiesc                 C   s
   t j S )N)r   CHROMErC   r   r   r   r   default_capabilities   s   
z$ChromiumOptions.default_capabilities)r
   N)__name__
__module____qualname__rG   r   propertyr   r   setterr   r"   r   r/   r9   r:   dictr<   r   intr>   rJ   rL   __classcell__r   r   r   r   r	      s*    
&	r	   )r$   r1   typingr   r   r   r   r   .selenium.webdriver.common.desired_capabilitiesr   !selenium.webdriver.common.optionsr   r	   r   r   r   r   <module>   s   