
    X jb                     N    S SK r S SKrS SKJr  S SKJr  S SKJr   " S S\5      rg)    N)BinaryIO)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\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\\-  \-  \\   -  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    t/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/selenium/webdriver/chromium/options.pyr   ChromiumOptions.__init__   s>    %'+-&(NP"-1+0"    c                     U R                   $ )z>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                   $ )z4Returns the address of the remote devtools instance.)r   r   s    r   debugger_address ChromiumOptions.debugger_address7   s     %%%r   c                 P    [        U[        5      (       d  [        S5      eXl        g)zSet the address of the remote devtools instance for active wait connection.

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&   <   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)z9Returns 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>._decodeK   s'     ##INN$45<<WEEr   rbN)r   r    r   openappendr   )r   r/   encoded_extensions	extensionfs        r   
extensionsChromiumOptions.extensionsG   sp    	Fx 	FC 	F  ..Ii&!"))'!*5 '& / "$4$444 '&s   A!!
A0	r5   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)zlAdd the path to an extension to be extracted to 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   r3   OSError
ValueError)r   r5   extension_to_adds      r   add_extensionChromiumOptions.add_extensionX   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)zAdd Base64-encoded string with extension data to be extracted to ChromeDriver.

Args:
    extension: Base64 encoded string with extension data.
r:   N)r   r3   rA   )r   r5   s     r   add_encoded_extension%ChromiumOptions.add_encoded_extensiong   s'     ##I.788r   c                     U R                   $ )z:Returns a dictionary of experimental options for chromium.r   r   s    r   experimental_options$ChromiumOptions.experimental_optionsr        )))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.
NrI   )r   rM   r   s      r   add_experimental_option'ChromiumOptions.add_experimental_optionw   s     ,1""4(r   c                     U R                   $ )zKReturn whether webextension support is enabled for Chromium-based browsers.)r   r   s    r   enable_webextensions$ChromiumOptions.enable_webextensions   rL   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   rR   rS      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.
r7   binaryargsdebuggerAddress)
_capsrJ   copymobile_optionsupdater7   r   rU   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   CHROMEr`   r   s    r   default_capabilities$ChromiumOptions.default_capabilities   s    "))..00r   )r   r   r   r   r   r   )r	   N)__name__
__module____qualname____firstlineno__rc   r   propertyr    r   setterr%   listr7   rC   rF   dictrJ   intrO   boolrR   rf   rj   __static_attributes____classcell__)r   s   @r   r   r      s   
C1 % % % &S &T & & &#* & & 'c 'd ' ' 5DI 5 5 9s 9t 9	9s 	9t 	9 *d * *1C 1c	D8H4PS98T 1Y] 1 *d * *   1$ 14 1 !1< * 1d 1 1r   r   )	r+   r;   typingr   .selenium.webdriver.common.desired_capabilitiesr   !selenium.webdriver.common.optionsr   r    r   r   <module>r|      s$   $  	  N 8a1j a1r   