
    i                     V    S SK r S SKrS SKJrJrJr  S SKJr  S SKJ	r	   " S S\	5      r
g)    N)BinaryIOOptionalUnion)DesiredCapabilities)
ArgOptionsc            	         ^  \ rS rSrSrSU 4S jjr\S\4S j5       r\R                  S\SS4S j5       r\S\
\   4S	 j5       r\R                  S\SS4S
 j5       r\S\\   4S j5       rS\SS4S jrS\SS4S jr\S\4S j5       rS\S\\\\\\   4   SS4S jr\S\4S j5       r\R                  S\SS4S j5       rS\4S jr\S\4S j5       rSrU =r$ )ChromiumOptions   zgoog:chromeOptionsreturnNc                 v   > [         TU ]  5         SU l        / U l        / U l        0 U l        SU l        SU l        g)z1Initialize ChromiumOptions with default settings. NF)super__init___binary_location_extension_files_extensions_experimental_options_debugger_address_enable_webextensions)self	__class__s    PC:\des-py\RoboSAPF\venv\Lib\site-packages\selenium\webdriver\chromium\options.pyr   ChromiumOptions.__init__   s>    %'+-&(RT"04+0"    c                     U R                   $ )zE
Returns:
    The location of the binary, otherwise an empty string.
)r   r   s    r   binary_locationChromiumOptions.binary_location'   s     $$$r   valuec                 d    [        U[        5      (       d  [        U R                  5      eXl        g)zbAllows 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   r   /   s(     %%%D6677 %r   c                     U R                   $ )z;
Returns:
    The address of the remote devtools instance.
)r   r   s    r   debugger_address ChromiumOptions.debugger_address:   s     %%%r   c                 P    [        U[        5      (       d  [        S5      eXl        g)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'   r(   B   s#     %%%?@@!&r   c                     S[         S[        4S jn/ nU R                   H/  n[        US5       nUR	                  U" U5      5        SSS5        M1     X R
                  -   $ ! , (       d  f       MP  = f)z@
Returns:
    A list of encoded extensions that will be loaded.
	file_datar   c                 h    [         R                  " U R                  5       5      R                  S5      $ )Nzutf-8)base64	b64encodereaddecode)r+   s    r   _decode+ChromiumOptions.extensions.<locals>._decodeU   s'     ##INN$45<<WEEr   rbN)r   r"   r   openappendr   )r   r1   encoded_extensions	extensionfs        r   
extensionsChromiumOptions.extensionsN   sp    	Fx 	FC 	F  ..Ii&!"))'!*5 '& / "$4$444 '&s   A!!
A0	r7   c                 4   U(       a  [         R                  R                  [         R                  R                  U5      5      n[         R                  R	                  U5      (       a  U R
                  R                  U5        g[        S5      e[        S5      e)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   r5   OSError
ValueError)r   r7   extension_to_adds      r   add_extensionChromiumOptions.add_extensionb   sj     !wwrww/A/A)/LMww~~.//%%,,-=>CDD788r   c                 ^    U(       a  U R                   R                  U5        g[        S5      e)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.
r<   N)r   r5   rC   )r   r7   s     r   add_encoded_extension%ChromiumOptions.add_encoded_extensionr   s'     ##I.788r   c                     U R                   $ )zA
Returns:
    A dictionary of experimental options for chromium.
r   r   s    r   experimental_options$ChromiumOptions.experimental_options~   s     )))r   namec                      X R                   U'   g)zAdds an experimental option which is passed to chromium.

Args:
    name: The experimental option name.
    value: The option value.
NrK   )r   rN   r   s      r   add_experimental_option'ChromiumOptions.add_experimental_option   s     ,1""4(r   c                     U R                   $ )z
Returns:
    Whether webextension support is enabled for Chromium-based browsers.
    True if webextension support is enabled, False otherwise.
)r   r   s    r   enable_webextensions$ChromiumOptions.enable_webextensions   s     )))r   c                     Xl         U(       a0  SS/nU H%  nX0R                  ;  d  M  U R                  U5        M'     gSS/nU H/  nX0R                  ;   d  M  U R                  R                  U5        M1     g)a|  Enables or disables webextension support for Chromium-based browsers.

Args:
    value: True to enable webextension support, False to disable.

Notes:
    - When enabled, this automatically adds the required Chromium flags:
        - --enable-unsafe-extension-debugging
        - --remote-debugging-pipe
    - When disabled, this removes BOTH flags listed above, even if they were manually added via add_argument()
      before enabling webextensions.
    - Enabling --remote-debugging-pipe makes the connection b/w chromedriver
      and the browser use a pipe instead of a port, disabling many CDP functionalities
      like devtools
z#--enable-unsafe-extension-debuggingz--remote-debugging-pipeN)r   
_argumentsadd_argumentremove)r   r   required_flagsflagflags_to_removes        r   rS   rT      sn    " &+"CE^_N&.%%d+ '
  EF_`O'??*OO**40 (r   c                    U R                   nU R                  R                  5       nU R                  (       a  UR	                  U R                  5        U R
                  US'   U R                  (       a  U R                  US'   U R                  US'   U R                  (       a  U R                  US'   X!U R                  '   U$ )zqCreates a capabilities with all the options that have been set.

Returns:
    A dictionary with all set options.
r9   binaryargsdebuggerAddress)
_capsrL   copymobile_optionsupdater9   r   rV   r'   KEY)r   capschrome_optionss      r   to_capabilitiesChromiumOptions.to_capabilities   s     zz22779!!$"5"56'+|$'+';';N8$!%v  040E0EN,-'TXXr   c                 >    [         R                  R                  5       $ )N)r   CHROMEra   r   s    r   default_capabilities$ChromiumOptions.default_capabilities   s    "))..00r   )r   r   r   r   r   r   )r   N)__name__
__module____qualname____firstlineno__rd   r   propertyr"   r   setterr   r'   listr9   rE   rH   dictrL   r   intrP   boolrS   rg   rk   __static_attributes____classcell__)r   s   @r   r	   r	      s   
C1 % % % &S &T & & &(3- & & 	'c 	'd 	' 	' 5DI 5 5&9s 9t 9 
9s 
9t 
9 *d * *1C 1c3dSVi>W8X 1]a 1 *d * *   1$ 14 1 !1< * 1d 1 1r   r	   )r-   r=   typingr   r   r   .selenium.webdriver.common.desired_capabilitiesr   !selenium.webdriver.common.optionsr   r	    r   r   <module>r}      s'   $  	 , , N 8t1j t1r   