
    /_i                        d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZ ddlmZmZ ddlmZ ddlmZmZ ddlmZmZmZmZ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& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZImJZJ ddlKmLZL dd lMmNZN dd!lOmPZP dd"lQmRZR dd#lSmTZT dd$lUmVZV dd%lWmXZX dd&lYmZZZ dd'l[m\Z\ da]d8d)Z^d(e_fd*Z`	 d9d+e_d,eaePz  d-ebd.ebd/eAdz  d(ePfd0Zcd1ede5   d(e_fd2Ze G d3 d4e5      Zf G d6 d7ef      Zgy):zThe WebDriver implementation.    N)ABCMeta)	b64decodeurlsafe_b64encode)asynccontextmanagercontextmanager)import_module)Anycast)InvalidArgumentExceptionJavascriptExceptionNoSuchCookieExceptionNoSuchElementExceptionWebDriverException)Browser)BrowsingContext)	Emulation)Input)Network)Permissions)Script)Session)Storage)WebExtension)By)Dialog)
ArgOptionsBaseOptions)PrintOptions)Timeouts)
CredentialVirtualAuthenticatorOptionsrequired_virtual_authenticator)BidiConnection)ClientConfig)Command)ErrorHandler)FedCM)FileDetectorLocalFileDetector)LocatorConverter)Mobile)RemoteConnection)	ScriptKey)
ShadowRoot)SwitchTo)
WebElement)WebSocketConnection)
RelativeByreturnc                  (    t         st        d      a y y )Nz"selenium.webdriver.common.bidi.cdp)cdpr        b/var/www/html/land_sniper/venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py
import_cdpr9   Q   s    @A r7   c                 z    t        j                  |       } i }| j                         D ]
  \  }}|||<    di g|diS )a~  Makes a W3C alwaysMatch capabilities object.

    Filters out capability names that are not in the W3C spec. Spec-compliant
    drivers will reject requests containing unknown capability names.

    Moves the Firefox profile, if present, from the old location to the new Firefox
    options object.

    Args:
        caps: A dictionary of capabilities requested by the caller.
    capabilities)
firstMatchalwaysMatch)copydeepcopyitems)capsalways_matchkvs       r8   _create_capsrE   W   sK     ==DL

 1QB4MNNr7   r;   command_executor
keep_aliveignore_local_proxyclient_configc                 R    t        |t              r#|xs t        |      }||_        t	        |      }ddlm} ddlm} ddl	m
} ddlm} ||||g}	t         fd|	D        t              }
t        |d	      r#|j                  r|j                  j                  }n|} |
||||
      S )N)remote_server_addr)rI   r   )ChromeRemoteConnection)EdgeRemoteConnection)FirefoxRemoteConnection)SafariRemoteConnectionc              3   `   K   | ]%  }|j                   j                  d       k(  s"| ' yw)browserNameN)browser_nameget).0cr;   s     r8   	<genexpr>z(get_remote_connection.<locals>.<genexpr>{   s(     _!Q^^|?O?OP]?^-^A_s   #..rI   )rK   rG   ignore_proxyrI   )
isinstancestrr$   rK   r,   +selenium.webdriver.chrome.remote_connectionrL   )selenium.webdriver.edge.remote_connectionrM   ,selenium.webdriver.firefox.remote_connectionrN   +selenium.webdriver.safari.remote_connectionrO   nexthasattrrI   )r;   rF   rG   rH   rI   rL   rM   rN   rO   
candidateshandlerrK   s   `           r8   get_remote_connectionrb   j   s     "C(%ZIY)Z+;(+-HRNTR(*>@VXopJ_z_aqrG16F6T6T-;;NN--'#	 r7   optionsc                    di i}g }| D ]!  }|j                  |j                                # t        |      }i }t        |      D ]n  }|}|dz   |k  s||   j	                         }|D ]I  }	|	||dz      j	                         v s||   |	   ||dz      |	   k(  s1|j                  |	||   |	   i       K p i }
|j                         D ]
  \  }}||
|<    |D ]  }|
D ]  }||=   |
|d   d<   ||d   d<   |S )Nr;      r=   r<   )appendto_capabilitieslenrangekeysupdater@   )rc   r;   optsopt	opts_sizesamesiesi	min_index
first_keyskysalwaysrC   rD   opt_dicts                 r8   create_matchesrv      sW   $2B#7LD +C'')*+D	IH 9 E	q59i--/J! E$q1u+**,,Is+tAE{3/?? d9oc.B(CDEE F  1q	   	A	 39L /15L .r7   c                       e Zd ZdZy)BaseWebDriverzAbstract Base Class for all Webdriver subtypes.

    ABC's allow custom implementations of Webdriver to be registered so
    that isinstance type checks will succeed.
    N)__name__
__module____qualname____doc__r6   r7   r8   rx   rx      s    r7   rx   )	metaclassc                   `   e Zd ZdZeZeZ	 	 	 	 	 	 	 ddee	z  de
dedz  deee   z  dz  dedz  dee   dz  d	edz  d
dfdZd
efdZddZdee   dz  dedz  dej,                  dz  fdZed        Zed
efd       Zed
efd       ZddZddZde d
dfdZ!d Z"ded
efdZ#d Z$dede fdZ%dd ed!e ee&f   dz  d
e ee&f   fd"Z'd#ed
dfd$Z(ed
efd%       Z)dd&ed
e*fd'Z+d(e*d
dfd)Z,d
ee   fd*Z-d&efd+Z.d&ed
e fd,Z/ed
efd-       Z0ed
efd.       Z1dd/Z2dd0Z3ed
efd1       Z4ed
ee   fd2       Z5dd3Z6dd4Z7dd5Z8dd6e9dz  d
efd7Z:ed
e;fd8       Z<dd9Z=dd:Z>dd;Z?d
ee    fd<Z@d
e dz  fd=ZAdd>ZBdd?ZCdd@ZDdAeEd
dfdBZFdAeEd
dfdCZGdAeEd
dfdDZHed
eIfdE       ZJeJj                  ddF       ZJeLj                  dfdGedz  d
efdHZNeLj                  dfdGedz  d
ee   fdIZOed
e fdJ       ZPd
e
fdKZQd
e
fdLZRd
eSfdMZTd
efdNZUddOed
dfdPZVddOed
e fdQZWddReEdSeEdOed
e fdTZXdd
e fdUZYdOed
dfdVZZd
e fdWZ[dd
e fdXZ\ed
efdY       Z]e]j                  ddZ       Z]ed
e fd[       Z^e^j                  dd\       Z^d
e_e&e`f   fd]Zaebd^        Zced
edfd_       Zedd`Zfed
egfda       Zhed
eifdb       Zjed
ekfdc       Zled
emfdd       Zned
eofde       Zped
eqfdf       Zred
esfdg       Zted
eufdh       Zved
ewfdi       Zxdj Zydezd
dfdkZ{ed
edz  fdl       Z|e}ddm       Z~e}dned
dfdo       Ze}d
ee   fdp       Ze}dqeez  d
dfdr       Ze}dds       Ze}dte
d
dfdu       Zd
efdvZdwedxed
dfdyZddzZed
efd{       Zed
e
fd|       Zdd}Zed
efd~       ZddZy)	WebDrivera  Control a browser by sending commands to a remote WebDriver server.

    This class expects the remote server to be running the WebDriver wire protocol
    as defined at https://www.selenium.dev/documentation/legacy/json_wire_protocol/.

    Attributes:
    -----------
    session_id - String ID of the browser session started and controlled by this WebDriver.
    capabilities - Dictionary of effective capabilities of this browser session as returned
        by the remote server. See https://www.selenium.dev/documentation/legacy/desired_capabilities/
    command_executor : str or remote_connection.RemoteConnection object used to execute commands.
    error_handler - errorhandler.ErrorHandler object used to handle errors.
    NrF   rG   file_detectorrc   locator_converterweb_element_clsrI   r3   c                 .   |t        d      t        |t              rt        |      }d}	n|j	                         }|j
                  }	|| _        t        | j                  t        t        f      rt        ||||	|      | _        d| _
        d| _        i | _        i | _        t               | _        t!        |       | _        t%        |       | _        |xs
 t)               | _        |xs
 t-               | _        |xs | j0                  | _        d| _        | j5                          | j7                  |       t9        |       | _        d| _        d| _        d| _         d| _!        d| _"        d| _#        d| _$        d| _%        d| _&        d| _'        d| _(        d| _)        y)a  Create a new driver instance that issues commands using the WebDriver protocol.

        Args:
            command_executor: Either a string representing the URL of the remote
                server or a custom remote_connection.RemoteConnection object.
                Defaults to 'http://127.0.0.1:4444/wd/hub'.
            keep_alive: (Deprecated) Whether to configure
                remote_connection.RemoteConnection to use HTTP keep-alive.
                Defaults to True.
            file_detector: Pass a custom file detector object during
                instantiation. If None, the default LocalFileDetector() will be
                used.
            options: Instance of a driver options.Options class.
            locator_converter: Custom locator converter to use. Defaults to None.
            web_element_cls: Custom class to use for web elements. Defaults to
                WebElement.
            client_config: Custom client configuration to use. Defaults to None.
        Nz`missing 1 required keyword-only argument: 'options' (instance of driver `options.Options` class)F)rF   rG   rH   rI   T)*	TypeErrorrX   listrv   rg   _ignore_local_proxyrF   rY   bytesrb   
_is_remote
session_idrA   pinned_scriptsr&   error_handlerr/   
_switch_tor+   _mobiler)   r   r*   r   _web_element_cls_authenticator_idstart_clientstart_sessionr'   _fedcm_websocket_connection_script_network_browser_bidi_session_browsing_context_storage_webextension_permissions
_emulation_input	_devtools)
selfrF   rG   r   rc   r   r   rI   r;   r   s
             r8   __init__zWebDriver.__init__   s   8 ?r  &)'2L"'"224L")"="= 0d++c5\:$9!1%#6+%D! &*$&	.0)^"4.d|*A.?.A!2!H6F6H / H43H3H!%<(DkAE"&*(,(,-19=(,2604,0$(%)r7   c                 z    dt        |       j                   dt        |       j                   d| j                   dS )N<.z (session="z")>)typerz   ry   r   r   s    r8   __repr__zWebDriver.__repr__  s9    4:(()4:+>+>*?{4??J[[^__r7   c                     | S Nr6   r   s    r8   	__enter__zWebDriver.__enter__  s    r7   exc_typeexc	tracebackc                 $    | j                          y r   )quit)r   r   r   r   s       r8   __exit__zWebDriver.__exit__  s     			r7   c              /      K   d}t        | j                  |      s| j                  } ||i || _        	 d |r|| _        yy# |r|| _        w w xY ww)aB  Override the current file detector temporarily within a limited context.

        Ensures the original file detector is set after exiting the context.

        Args:
            file_detector_class: Class of the desired file detector. If the
                class is different from the current file_detector, then the
                class is instantiated with args and kwargs and used as a file
                detector during the duration of the context manager.
            *args: Optional arguments that get passed to the file detector class
                during instantiation.
            **kwargs: Keyword arguments, passed the same way as args.

        Example:
            ```
            with webdriver.file_detector_context(UselessFileDetector):
                someinput.send_keys("/etc/hosts")
            ````
        N)rX   r   )r   file_detector_classargskwargslast_detectors        r8   file_detector_contextzWebDriver.file_detector_context  sc     * $,,.AB ..M!4d!Ef!ED	3%2" }%2" s   2AA AAAc                     | j                   S r   )r   r   s    r8   mobilezWebDriver.mobile>  s    ||r7   c                 R    d| j                   v r| j                   d   S t        d      )z=Returns the name of the underlying browser for this instance.rQ   z1browserName not specified in session capabilities)rA   KeyErrorr   s    r8   namezWebDriver.nameB  s+     DII%99]++JKKr7   c                      y)zxCalled before starting a new session.

        This method may be overridden to define custom startup behavior.
        Nr6   r   s    r8   r   zWebDriver.start_clientI  s    
 	r7   c                      y)zCalled after executing a quit command.

        This method may be overridden to define custom shutdown
        behavior.
        Nr6   r   s    r8   stop_clientzWebDriver.stop_clientP  s     	r7   r;   c                 :   t        |      }	 | j                  t        j                  |      d   }|j	                  d      | _        |j	                  d      | _        y# t        $ r4 t        | d      r&| j                  | j                  j                           w xY w)zCreates a new session with the desired capabilities.

        Args:
            capabilities: A capabilities dict to start the session with.
        value	sessionIdr;   serviceN)rE   executer%   NEW_SESSIONrS   r   rA   	Exceptionr_   r   stop)r   r;   rA   responses       r8   r   zWebDriver.start_sessionX  s     L)	||G$7$7>wGH&ll;7DO ^4DI 	tY'DLL,D!!#	s   AA =Bc                 `    t        |t              r0i }|j                         D ]  \  }} j                  |      ||<    |S t        | j                        rd|j
                  iS t        | j                        rd|j
                  iS t        |t              rt         fd|D              S |S )N#element-6066-11e4-a52e-4f735466cecf"shadow-6066-11e4-a52e-4f735466cecfc              3   @   K   | ]  }j                  |        y wr   )_wrap_valuerT   itemr   s     r8   rV   z(WebDriver._wrap_value.<locals>.<genexpr>s  s     A4((.A   )rX   dictr@   r   r   id_shadowroot_clsr   )r   r   	convertedkeyvals   `    r8   r   zWebDriver._wrap_valueh  s    eT"I!KKM 7S!%!1!1#!6	#7eT2239588DDeT1128%((CCeT"A5AAAr7   
element_idc                 &    | j                  | |      S )z6Creates a web element with the specified `element_id`.)r   )r   r   s     r8   create_web_elementzWebDriver.create_web_elementv  s    $$T:66r7   c                 .    t        |t              r_d|v r j                  |d         S d|v r j                   |d         S |j	                         D ]  \  }} j                  |      ||<    |S t        |t              rt         fd|D              S |S )Nr   r   c              3   @   K   | ]  }j                  |        y wr   )_unwrap_valuer   s     r8   rV   z*WebDriver._unwrap_value.<locals>.<genexpr>  s     CT**40Cr   )rX   r   r   r   r@   r   r   )r   r   r   r   s   `   r8   r   zWebDriver._unwrap_valuez  s    eT"4=..u5Z/[\\3u<++D%8\2]^^!KKM 5S!//4c
5LeT"CUCCCr7   cmdcmd_argsc                 2    | j                  d||d      d   S )a  Execute Chrome Devtools Protocol command and get returned result.

        The command and command args should follow chrome devtools protocol domains/commands:
          - https://chromedevtools.github.io/devtools-protocol/

        Args:
            cmd: Command name.
            cmd_args: Command args. Empty dict {} if there is no command args.

        Returns:
            A dict, empty dict {} if there is no result to return. To
            getResponseBody: {'base64Encoded': False, 'body': 'response body
            string'}

        Example:
            `driver.execute_cdp_cmd("Network.getResponseBody", {"requestId": requestId})`
        executeCdpCommand)r   paramsr   )r   )r   r   r   s      r8   execute_cdp_cmdzWebDriver.execute_cdp_cmd  s!    $ ||/1QRSZ[[r7   driver_commandr   c                 ~   | j                  |      }| j                  r$|sd| j                  i}nd|vr| j                  |d<   t        t        | j                        j                  ||      }|rA| j                  j                  |       | j                  |j                  dd            |d<   |S dd| j                  dS )aJ  Sends a command to be executed by a command.CommandExecutor.

        Args:
            driver_command: The name of the command to execute as a string.
            params: A dictionary of named parameters to send with the command.

        Returns:
            The command's JSON response loaded into a dictionary object.
        r   r   Nr   )successr   r   )
r   r   r
   r,   rF   r   r   check_responser   rS   )r   r   r   r   s       r8   r   zWebDriver.execute  s     !!&)??%t7F*&*oo{#($*?*?@HHY_`--h7 $ 2 28<<3N OHWO t$//JJr7   urlc                 H    | j                  t        j                  d|i       y)a  Navigate the browser to the specified URL.

        The method does not return until the page is fully loaded (i.e. the
        onload event has fired) in the current window or tab.

        Args:
            url: The URL to be opened by the browser. Must include the protocol
                (e.g., http://, https://).

        Example:
            `driver.get("https://example.com")`
        r   N)r   r%   GET)r   r   s     r8   rS   zWebDriver.get  s     	W[[5#,/r7   c                 `    | j                  t        j                        j                  dd      S )zReturns the title of the current page.

        Example:
            ```
            element = driver.find_element(By.ID, "foo")
            print(element.title())
            ```
        r    )r   r%   	GET_TITLErS   r   s    r8   titlezWebDriver.title  s&     ||G--.227B??r7   scriptc                 N    t        |      }|| j                  |j                  <   |S )zStore a JavaScript script by a unique hashable ID for later execution.

        Example:
            `script = "return document.getElementById('foo').value"`
        )r-   r   r   )r   r   
script_keyscript_key_instances       r8   
pin_scriptzWebDriver.pin_script  s,     (
36</223""r7   r   c                     	 | j                   j                  |j                         y# t        $ r t        d| d| j                          dw xY w)zfRemove a pinned script from storage.

        Example:
            `driver.unpin(script_key)`
        zNo script with key: z existed in N)r   popr   r   )r   r   s     r8   unpinzWebDriver.unpin  sT    	k##JMM2 	k1*\$J]J]I^_`fjj	ks	   %( &Ac                 ,    t        | j                        S )zzReturn a list of all pinned scripts.

        Example:
            `pinned_scripts = driver.get_pinned_scripts()`
        )r   r   r   s    r8   get_pinned_scriptszWebDriver.get_pinned_scripts  s     D''((r7   c                     t        |t              r	 | j                  |j                     }t        |      }t        j                  }| j                  |||d      d   S # t        $ r t        d      w xY w)a  Synchronously Executes JavaScript in the current window/frame.

        Args:
            script: The javascript to execute.
            *args: Any applicable arguments for your JavaScript.

        Example:
            ```
            id = "username"
            value = "test_user"
            driver.execute_script("document.getElementById(arguments[0]).value = arguments[1];", id, value)
            ```
        z Pinned script could not be foundr   r   r   )
rX   r-   r   r   r   r   r   r%   W3C_EXECUTE_SCRIPTr   r   r   r   converted_argscommands        r8   execute_scriptzWebDriver.execute_script  sy     fi(N,,VYY7 d,,||G%OPQXYY  N)*LMMNs   A A3c                 h    t        |      }t        j                  }| j                  |||d      d   S )a  Asynchronously Executes JavaScript in the current window/frame.

        Args:
            script: The javascript to execute.
            *args: Any applicable arguments for your JavaScript.

        Example:
            ```
            script = "var callback = arguments[arguments.length - 1]; "
                "window.setTimeout(function(){ callback('timeout') }, 3000);"
            driver.execute_async_script(script)
            ```
        r   r   )r   r%   W3C_EXECUTE_SCRIPT_ASYNCr   r   s        r8   execute_async_scriptzWebDriver.execute_async_script  s4     d22||G%OPQXYYr7   c                 F    | j                  t        j                        d   S )z!Gets the URL of the current page.r   )r   r%   GET_CURRENT_URLr   s    r8   current_urlzWebDriver.current_url       ||G334W==r7   c                 F    | j                  t        j                        d   S )z$Gets the source of the current page.r   )r   r%   GET_PAGE_SOURCEr   s    r8   page_sourcezWebDriver.page_source   r  r7   c                 B    | j                  t        j                         y)zCloses the current window.N)r   r%   CLOSEr   s    r8   closezWebDriver.close%  s    W]]#r7   c                 6   	 | j                  t        j                         | j                          t	        t
        | j                        }|j                          y# | j                          t	        t
        | j                        }|j                          w xY w)z4Quits the driver and closes every associated window.N)r   r%   QUITr   r
   r,   rF   r	  )r   executors     r8   r   zWebDriver.quit)  sm    	LL&,d.C.CDHNN ,d.C.CDHNNs   A <Bc                 F    | j                  t        j                        d   S )z)Returns the handle of the current window.r   )r   r%   W3C_GET_CURRENT_WINDOW_HANDLEr   s    r8   current_window_handlezWebDriver.current_window_handle2  s     ||GAAB7KKr7   c                 F    | j                  t        j                        d   S )z>Returns the handles of all windows within the current session.r   )r   r%   W3C_GET_WINDOW_HANDLESr   s    r8   window_handleszWebDriver.window_handles7  s     ||G::;GDDr7   c                 H    t         j                  }| j                  |d       y)z5Maximizes the current window that webdriver is using.N)r%   W3C_MAXIMIZE_WINDOWr   )r   r   s     r8   maximize_windowzWebDriver.maximize_window<  s    --Wd#r7   c                 B    | j                  t        j                         y)z<Invokes the window manager-specific 'full screen' operation.N)r   r%   FULLSCREEN_WINDOWr   s    r8   fullscreen_windowzWebDriver.fullscreen_windowA  s    W../r7   c                 B    | j                  t        j                         y)z9Invokes the window manager-specific 'minimize' operation.N)r   r%   MINIMIZE_WINDOWr   s    r8   minimize_windowzWebDriver.minimize_windowE  s    W,,-r7   print_optionsc                 p    i }|r|j                         }| j                  t        j                  |      d   S )zTakes PDF of the current page.

        The driver makes a best effort to return a PDF based on the
        provided parameters.
        r   )to_dictr   r%   
PRINT_PAGE)r   r  rc   s      r8   
print_pagezWebDriver.print_pageI  s6     )+#++-G||G..8AAr7   c                     | j                   S )aP  Return an object containing all options to switch focus into.

        Returns:
            An object containing all options to switch focus into.

        Examples:
            `element = driver.switch_to.active_element`
            `alert = driver.switch_to.alert`
            `driver.switch_to.default_content()`
            `driver.switch_to.frame("frame_name")`
            `driver.switch_to.frame(1)`
            `driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0])`
            `driver.switch_to.parent_frame()`
            `driver.switch_to.window("main")`
        )r   r   s    r8   	switch_tozWebDriver.switch_toU  s    " r7   c                 B    | j                  t        j                         y)z.Goes one step backward in the browser history.N)r   r%   GO_BACKr   s    r8   backzWebDriver.backi      W__%r7   c                 B    | j                  t        j                         y)z-Goes one step forward in the browser history.N)r   r%   
GO_FORWARDr   s    r8   forwardzWebDriver.forwardm  s    W''(r7   c                 B    | j                  t        j                         y)zRefreshes the current page.N)r   r%   REFRESHr   s    r8   refreshzWebDriver.refreshq  r&  r7   c                 F    | j                  t        j                        d   S )zGet all cookies visible to the current WebDriver instance.

        Returns:
            A list of dictionaries, corresponding to cookies visible in the
            current session.
        r   )r   r%   GET_ALL_COOKIESr   s    r8   get_cookieszWebDriver.get_cookiesu  s     ||G334W==r7   c                     |r|j                         rt        d      t        j                  t              5  | j                  t        j                  d|i      d   cddd       S # 1 sw Y   yxY w)a  Get a single cookie by name (case-sensitive,).

        Returns:
             A cookie dictionary or None if not found.

        Raises:
            ValueError if the name is empty or whitespace.

        Example:
            `cookie = driver.get_cookie("my_cookie")`
        Cookie name cannot be emptyr   r   N)isspace
ValueError
contextlibsuppressr   r   r%   
GET_COOKIEr   r   s     r8   
get_cookiezWebDriver.get_cookie~  se     t||~:;;  !67 	M<< 2 2VTNCGL	M 	M 	M s   %A&&A/c                     |r|j                         rt        d      | j                  t        j                  d|i       y)zDelete a single cookie with the given name (case-sensitive).

        Raises:
            ValueError if the name is empty or whitespace.

        Example:
            `driver.delete_cookie("my_cookie")`
        r1  r   N)r2  r3  r   r%   DELETE_COOKIEr7  s     r8   delete_cookiezWebDriver.delete_cookie  s3     t||~:;;W**VTN;r7   c                 B    | j                  t        j                         y)z/Delete all cookies in the scope of the session.N)r   r%   DELETE_ALL_COOKIESr   s    r8   delete_all_cookieszWebDriver.delete_all_cookies  s    W//0r7   c                     d|v r,|d   dv sJ | j                  t        j                  d|i       y| j                  t        j                  d|i       y)aZ  Adds a cookie to your current session.

        Args:
            cookie_dict: A dictionary object, with required keys - "name" and
                "value"; Optional keys - "path", "domain", "secure", "httpOnly",
                "expiry", "sameSite".

        Examples:
            `driver.add_cookie({"name": "foo", "value": "bar"})`
            `driver.add_cookie({"name": "foo", "value": "bar", "path": "/"})`
            `driver.add_cookie({"name": "foo", "value": "bar", "path": "/", "secure": True})`
            `driver.add_cookie({"name": "foo", "value": "bar", "sameSite": "Strict"})`
        sameSite)StrictLaxNonecookieN)r   r%   
ADD_COOKIE)r   cookie_dicts     r8   
add_cookiezWebDriver.add_cookie  sR     $z*.GGGGLL++h-DELL++h-DEr7   time_to_waitc           	      r    | j                  t        j                  dt        t	        |      dz        i       y)a  Set a sticky implicit timeout for element location and command completion.

        This method sets a timeout that applies to all element location strategies
        for the duration of the session. It only needs to be called once per session.
        To set the timeout for asynchronous script execution, see set_script_timeout.

        Args:
            time_to_wait: Amount of time to wait (in seconds).

        Example:
            `driver.implicitly_wait(30)`
        implicit  Nr   r%   SET_TIMEOUTSintfloatr   rH  s     r8   implicitly_waitzWebDriver.implicitly_wait  s-     	W))JE,<ORV<V8W+XYr7   c           	      r    | j                  t        j                  dt        t	        |      dz        i       y)aK  Set the timeout for asynchronous script execution.

        This timeout specifies how long a script can run during an
        execute_async_script call before throwing an error.

        Args:
            time_to_wait: The amount of time to wait (in seconds).

        Example:
            `driver.set_script_timeout(30)`
        r   rK  NrL  rP  s     r8   set_script_timeoutzWebDriver.set_script_timeout  s-     	W))Hc%:MPT:T6U+VWr7   c           	          	 | j                  t        j                  dt        t	        |      dz        i       y# t
        $ r2 | j                  t        j                  t	        |      dz  dd       Y yw xY w)a,  Set the timeout for page load completion.

        This specifies how long to wait for a page load to complete before
        throwing an error.

        Args:
            time_to_wait: The amount of time to wait (in seconds).

        Example:
            `driver.set_page_load_timeout(30)`
        pageLoadrK  z	page load)msr   N)r   r%   rM  rN  rO  r   rP  s     r8   set_page_load_timeoutzWebDriver.set_page_load_timeout  sf    	hLL--
Cl@SVZ@Z<[/\]! 	hLL--eL6ID6PZe/fg	hs   7: 8A54A5c                     | j                  t        j                        d   }|j                  d      dz  |d<   |j                  d      dz  |d<   |j                  d      dz  |d<   t	        di |S )	a  Get all the timeouts that have been set on the current session.

        Returns:
            A named tuple with the following fields:
              - implicit_wait: The time to wait for elements to be found.
              - page_load: The time to wait for a page to load.
              - script: The time to wait for scripts to execute.

        Example:
            `driver.timeouts`
        r   rJ  rK  implicit_waitrU  	page_loadr   r6   )r   r%   GET_TIMEOUTSr   r   )r   timeoutss     r8   r\  zWebDriver.timeouts  ss     << 4 45g>$,LL$<t$C! (Z 84 ?%\\(3d:#(##r7   c                 f    | j                  t        j                  |j                               d   }y)a  Set all timeouts for the session.

        This will override any previously set timeouts.

        Example:
            ```
            my_timeouts = Timeouts()
            my_timeouts.implicit_wait = 10
            driver.timeouts = my_timeouts
            ```
        r   N)r   r%   rM  _to_json)r   r\  _s      r8   r\  zWebDriver.timeouts  s(     LL--x/@/@/BCGLr7   r   c                    | j                   j                  ||      \  }}t        |t              r2| j	                  ||      }|st        d|j                         |d   S | j                  t        j                  ||d      d   S )a7  Find an element given a By strategy and locator.

        Args:
            by: The locating strategy to use. Default is `By.ID`. Supported
                values include: By.ID, By.NAME, By.XPATH, By.CSS_SELECTOR,
                By.CLASS_NAME, By.TAG_NAME, By.LINK_TEXT, By.PARTIAL_LINK_TEXT,
                or RelativeBy.
            value: The locator value to use with the specified `by` strategy.

        Returns:
            The first matching WebElement found on the page.

        Example:
            `element = driver.find_element(By.ID, 'foo')`
        )byr   z%Cannot locate relative element with: r   usingr   r   )
r   convertrX   r2   find_elementsr   rootr   r%   FIND_ELEMENT)r   ra  r   elementss       r8   find_elementzWebDriver.find_element
  s      **222u=	Eb*%))Ru)=H,/TUWU\U\T]-^__A;||G00B2OPQXYYr7   c                    | j                   j                  ||      \  }}t        |t              rdj	                  t
        j                  d      dd       }t        j                  |d      }|t        d|       |j                  d      }d| d}| j                  ||j                               S | j                  t        j                  ||d	      d
   xs g S )aF  Find elements given a By strategy and locator.

        Args:
            by: The locating strategy to use. Default is `By.ID`. Supported
                values include: By.ID, By.NAME, By.XPATH, By.CSS_SELECTOR,
                By.CLASS_NAME, By.TAG_NAME, By.LINK_TEXT, By.PARTIAL_LINK_TEXT,
                or RelativeBy.
            value: The locator value to use with the specified `by` strategy.

        Returns:
            List of WebElements matching locator strategy found on the page.

        Example:
            `element = driver.find_elements(By.ID, 'foo')`
        r   NzfindElements.jsz*Could not find findElements.js in package utf8z/* findElements */return (z).apply(null, arguments);rb  r   )r   rd  rX   r2   joinry   splitpkgutilget_dataFileNotFoundErrordecoder   r  r   r%   FIND_ELEMENTS)r   ra  r   _pkgraw_dataraw_functionfind_element_jss          r8   re  zWebDriver.find_elements$  s      **222u=	Eb*%88HNN3/45D''.?@H'*TUYTZ([\\#??62L :<.HabO&&

EE ||G11R%3PQRYZ`^``r7   c                     | j                   S )z4Returns the drivers current capabilities being used.)rA   r   s    r8   r;   zWebDriver.capabilitiesC  s     yyr7   c                 @   t        |      j                         j                  d      st        j                  dt
        d       | j                         }	 t        |d      5 }|j                  |       ddd       ~y# 1 sw Y   xY w# t        $ r Y ~yw xY w# ~w xY w)	a  Save a screenshot of the current window to a PNG image file.

        Returns:
            False if there is any IOError, else returns True. Use full paths in your filename.

        Args:
            filename: The full path you wish to save your screenshot to. This
                should end with a `.png` extension.

        Example:
            `driver.get_screenshot_as_file("./screenshots/foo.png")`
        z.pngz^name used for saved screenshot does not match file type. It should end with a `.png` extension   
stacklevelwbNFT)
rY   lowerendswithwarningswarnUserWarningget_screenshot_as_pngopenwriteOSError)r   filenamepngfs       r8   get_screenshot_as_filez WebDriver.get_screenshot_as_fileH  s     8}""$--f5MMp
 ((*	h% 
   		 s<   B
 "A>4B
 >BB
 
	BB BB Bc                 $    | j                  |      S )a  Save a screenshot of the current window to a PNG image file.

        Returns:
            False if there is any IOError, else returns True. Use full paths in your filename.

        Args:
            filename: The full path you wish to save your screenshot to. This
                should end with a `.png` extension.

        Example:
            `driver.save_screenshot("./screenshots/foo.png")`
        )r  )r   r  s     r8   save_screenshotzWebDriver.save_screenshote  s     **844r7   c                 R    t        | j                         j                  d            S )zGets the screenshot of the current window as a binary data.

        Example:
            `driver.get_screenshot_as_png()`
        ascii)r   get_screenshot_as_base64encoder   s    r8   r  zWebDriver.get_screenshot_as_pngt  s#     668??HIIr7   c                 F    | j                  t        j                        d   S )zGet a base64-encoded screenshot of the current window.

        This encoding is useful for embedding screenshots in HTML.

        Example:
            `driver.get_screenshot_as_base64()`
        r   )r   r%   
SCREENSHOTr   s    r8   r  z"WebDriver.get_screenshot_as_base64|  s     ||G../88r7   windowHandlec                 p    | j                  |       | j                  t        |      t        |             y)aY  Sets the width and height of the current window.

        Args:
            width: The width in pixels to set the window to.
            height: The height in pixels to set the window to.
            windowHandle: The handle of the window to resize. Default is "current".

        Example:
            `driver.set_window_size(800, 600)`
        widthheightN"_check_if_window_handle_is_currentset_window_rectrN  )r   r  r  r  s       r8   set_window_sizezWebDriver.set_window_size  s-     	//=3u:c&kBr7   c                     | j                  |       | j                         }|j                  dd      r|d   }dD ci c]  }|||   
 c}S c c}w )zrGets the width and height of the current window.

        Example:
            `driver.get_window_size()`
        r   Nr  )r  get_window_rectrS   )r   r  sizerC   s       r8   get_window_sizezWebDriver.get_window_size  sS     	//=##%88GT"=D$78q47
888s   Axyc                 n    | j                  |       | j                  t        |      t        |            S )ai  Sets the x,y position of the current window.

        Args:
            x: The x-coordinate in pixels to set the window position.
            y: The y-coordinate in pixels to set the window position.
            windowHandle: The handle of the window to reposition. Default is "current".

        Example:
            `driver.set_window_position(0, 0)`
        r  r  r  )r   r  r  r  s       r8   set_window_positionzWebDriver.set_window_position  s0     	//=##c!fA#77r7   c                 v    | j                  |       | j                         }dD ci c]  }|||   
 c}S c c}w )zrGets the x,y position of the current window.

        Example:
            `driver.get_window_position()`
        r  )r  r  )r   r  positionrC   s       r8   get_window_positionzWebDriver.get_window_position  s<     	//='')(2318A;333s   6c                 >    |dk7  rt        j                  dd       yy)z5Warns if the window handle is not equal to `current`.currentz?Only 'current' window is supported for W3C compatible browsers.rz  r{  N)r  r  )r   r  s     r8   r  z,WebDriver._check_if_window_handle_is_current  s    9$MM[hij %r7   c                 F    | j                  t        j                        d   S )zGet the window's position and size.

        Returns:
            x, y coordinates and height and width of the current window.

        Example:
            `driver.get_window_rect()`
        r   )r   r%   GET_WINDOW_RECTr   s    r8   r  zWebDriver.get_window_rect  s     ||G334W==r7   c                 x    |||s|st        d      | j                  t        j                  ||||d      d   S )a  Set the window's position and size.

        Sets the x, y coordinates and height and width of the current window.
        This method is only supported for W3C compatible browsers; other browsers
        should use `set_window_position` and `set_window_size`.

        Example:
            `driver.set_window_rect(x=10, y=10)`
            `driver.set_window_rect(width=100, height=200)`
            `driver.set_window_rect(x=10, y=10, width=100, height=200)`
        z'x and y or height and width need values)r  r  r  r  r   )r   r   r%   SET_WINDOW_RECT)r   r  r  r  r  s        r8   r  zWebDriver.set_window_rect  sD     I!)fU*+TUU||G3311u`f5ghipqqr7   c                     | j                   S r   )_file_detectorr   s    r8   r   zWebDriver.file_detector  s    """r7   c                 b    |st        d      t        |t              st        d      || _        y)a  Set the file detector for keyboard input.

        By default, this is set to a file detector that does nothing.
        See FileDetector, LocalFileDetector, and UselessFileDetector.

        Args:
            detector: The detector to use. Must not be None.
        z,You may not set a file detector that is nullz+Detector has to be instance of FileDetectorN)r   rX   r(   r  )r   detectors     r8   r   zWebDriver.file_detector  s1     $%STT(L1$%RSS&r7   c                 F    | j                  t        j                        d   S )zuGets the current orientation of the device.

        Example:
            `orientation = driver.orientation`
        r   )r   r%   GET_SCREEN_ORIENTATIONr   s    r8   orientationzWebDriver.orientation  s     ||G::;GDDr7   c                     ddg}|j                         |v r#| j                  t        j                  d|i       yt	        d      )zSets the current orientation of the device.

        Args:
            value: Orientation to set it to.

        Example:
            `driver.orientation = "landscape"`
        	LANDSCAPEPORTRAITr  z>You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'N)upperr   r%   SET_SCREEN_ORIENTATIONr   )r   r   allowed_valuess      r8   r  zWebDriver.orientation  sA     &z2;;=N*LL77-9OP$%effr7   c                 2   t                | j                  j                  d      rI| j                  j                  d      }| j                  j                  d      j                  d      d   }n| j	                         \  }}|st        d      t        j                  |      | _        | j                  r| j                  | j                  fS | j                  d   j                         dk(  rt        d      t        || j                  j                  j                  | j                  j                  j                         | _	        | j                  j#                  | j                  j$                  j'                               }|D ])  }|j(                  | j*                  k(  s|j(                  } n | j                  j#                  | j                  j$                  j-                  d	            }|| j                  _        | j                  | j                  fS )
Nse:cdpse:cdpVersionr   r   2Unable to find url to connect to from capabilitiesrQ   firefoxzJCDP support for Firefox has been removed. Please switch to WebDriver BiDi.T)r9   rA   rS   rn  _get_cdp_detailsr   r5   import_devtoolsr   r   r~  RuntimeErrorr1   rF   rI   websocket_timeoutwebsocket_intervalr   targetget_targets	target_idr  attach_to_targetr   )r   ws_urlversiontargetsr  r  sessions          r8   start_devtoolszWebDriver.start_devtools	  s   99=="YY]]8,FiimmO4::3?BG"335OGV$%YZZ,,W5%%>>4#=#===99]#))+y8kll%8!!//AA!!//BB&
"
 ,,44T^^5J5J5V5V5XY 	F4#=#==",,		 ,,44T^^5J5J5[5[\egk5lm07""-~~t9999r7   c                P  K   t                | j                  j                  d      rI| j                  j                  d      }| j                  j                  d      j                  d      d   }n| j	                         \  }}|st        d      t        j                  |      }t        j                  |      4 d {   }|j                  |j                  j                                d {   }|D ])  }|j                  | j                  k(  s|j                  } n |j                        4 d {   }t        |t        |       d d d       d {    d d d       d {    y 7 7 7 =7 # 1 d {  7  sw Y   +xY w7 "# 1 d {  7  sw Y   y xY ww)Nr  r  r   r   r  )r9   rA   rS   rn  r  r   r5   r  open_cdpr   r  r  r  r  open_sessionr#   )	r   r  r  devtoolsconnr  r  r  r  s	            r8   bidi_connectionzWebDriver.bidi_connection(  sc     	99=="YY]]8,FiimmO4::3?BG"335OGV$%YZZ&&w/<<' 	= 	=4 LL)D)D)FGGG! ##t'A'AA & 0 0I ((3 = =w$Wc8<<= =	= 	= 	=G
= = = = =	= 	= 	= 	=s   B=F&?E2 F&-F0E41"F$F8E69F<E:FE8F!F&,F-F&4F6F8F:F	 FF	FF&F#FF#F&c                     | j                   s| j                          | j                  st        | j                   |       | _        | j                  S r   )r   _start_bidir   r   r   s    r8   r   zWebDriver.script?  s<    ))||!$"<"<dCDL||r7   c                 $   | j                   j                  d      r| j                   j                  d      }nt        d      t        || j                  j
                  j                  | j                  j
                  j                        | _        y )NwebSocketUrlr  )	rA   rS   r   r1   rF   rI   r  r  r   )r   r  s     r8   r  zWebDriver._start_bidiI  sj    99==(YY]]>2F$%YZZ%8!!//AA!!//BB&
"r7   c                     | j                   s| j                          t        | d      r| j                  t	        | j                         | _        | j                  S )Nr   )r   r  r_   r   r   r   s    r8   networkzWebDriver.networkU  sF    ))tZ(DMM,A#D$>$>?DM}}r7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )a  Returns a browser module object for BiDi browser commands.

        Returns:
            An object containing access to BiDi browser commands.

        Examples:
            `user_context = driver.browser.create_user_context()`
            `user_contexts = driver.browser.get_user_contexts()`
            `client_windows = driver.browser.get_client_windows()`
            `driver.browser.remove_user_context(user_context)`
        )r   r  r   r   r   s    r8   browserzWebDriver.browser_  s?     ))== #D$>$>?DM}}r7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )zBReturns the BiDi session object for the current WebDriver session.)r   r  r   r   r   s    r8   _sessionzWebDriver._sessiont  sD     ))%!()C)C!DD!!!r7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )a  Returns a browsing context module object for BiDi browsing context commands.

        Returns:
            An object containing access to BiDi browsing context commands.

        Examples:
            `context_id = driver.browsing_context.create(type="tab")`
            `driver.browsing_context.navigate(context=context_id, url="https://www.selenium.dev")`
            `driver.browsing_context.capture_screenshot(context=context_id)`
            `driver.browsing_context.close(context_id)`
        )r   r  r   r   r   s    r8   browsing_contextzWebDriver.browsing_context  sD     ))!!)%4T5O5O%PD"%%%r7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )aU  Returns a storage module object for BiDi storage commands.

        Returns:
            An object containing access to BiDi storage commands.

        Examples:
            ```
            cookie_filter = CookieFilter(name="example")
            result = driver.storage.get_cookies(filter=cookie_filter)
            cookie=PartialCookie("name", BytesValue(BytesValue.TYPE_STRING, "value")
            driver.storage.set_cookie(cookie=cookie, "domain"))
            cookie_filter=CookieFilter(name="example")
            driver.storage.delete_cookies(filter=cookie_filter)
            ```
        )r   r  r   r   r   s    r8   storagezWebDriver.storage  s?    " ))== #D$>$>?DM}}r7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )a  Get a permissions module object for BiDi permissions commands.

        Returns:
            An object containing access to BiDi permissions commands.

        Examples:
            ```
            from selenium.webdriver.common.bidi.permissions import PermissionDescriptor, PermissionState

            descriptor = PermissionDescriptor("geolocation")
            driver.permissions.set_permission(descriptor, PermissionState.GRANTED, "https://example.com")
            ```
        )r   r  r   r   r   s    r8   permissionszWebDriver.permissions  sD     ))$ +D,F,F GD   r7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )ay  Get a webextension module object for BiDi webextension commands.

        Returns:
            An object containing access to BiDi webextension commands.

        Examples:
            `extension_path = "/path/to/extension"`
            `extension_result = driver.webextension.install(path=extension_path)`
            `driver.webextension.uninstall(extension_result)`
        )r   r  r   r   r   s    r8   webextensionzWebDriver.webextension  sD     ))%!-d.H.H!ID!!!r7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )a  Get an emulation module object for BiDi emulation commands.

        Returns:
            An object containing access to BiDi emulation commands.

        Examples:
            ```
            from selenium.webdriver.common.bidi.emulation import GeolocationCoordinates

            coordinates = GeolocationCoordinates(37.7749, -122.4194)
            driver.emulation.set_geolocation_override(coordinates=coordinates, contexts=[context_id])
            ```
        )r   r  r   r   r   s    r8   	emulationzWebDriver.emulation  s?     ))??"'(B(BCDOr7   c                     | j                   s| j                          | j                  t        | j                         | _        | j                  S )a7  Get an input module object for BiDi input commands.

        Returns:
            An object containing access to BiDi input commands.

        Examples:
            ```
            from selenium.webdriver.common.bidi.input import KeySourceActions, KeyDownAction, KeyUpAction

            actions = KeySourceActions(id="keyboard", actions=[KeyDownAction(value="a"), KeyUpAction(value="a")])
            driver.input.perform_actions(driver.current_window_handle, [actions])
            driver.input.release_actions(driver.current_window_handle)
            ```
        )r   r  r   r   r   s    r8   inputzWebDriver.input  s?      ));; : :;DK{{r7   c                 |   dd l }dd l}|j                         }	 | j                  j	                  d      dk(  r+| j                  j	                  d      j	                  d      }nG| j                  j	                  d      dv r*| j                  j	                  d      j	                  d      }|j                  d	d
 d      }|j                  |j                        }|j	                  d      }|j	                  d      }dd l
}	|	j                  d|      j                  d      }
|
|fS # t
        $ r t        d      w xY w)Nr   rQ   chromezgoog:chromeOptionsdebuggerAddress)MicrosoftEdgewebview2zms:edgeOptionszCan't get debugger address.r   zhttp://z/json/versionr   webSocketDebuggerUrlz
.*/(\d+)\.re   )jsonurllib3PoolManagerrA   rS   AttributeErrorr   requestloadsdataresearchgroup)r   r  r  httpdebugger_addressresr  browser_versionwebsocket_urlr  r  s              r8   r  zWebDriver._get_cdp_details  s   ""$	Dyy}}]+x7#'99==1E#F#J#JK\#] }-1NN#'99==1A#B#F#FGX#Y  ll5G,<+=]"KLzz#((#((9-!78))M?;AA!D%%  	D$%BCC	Ds   BD& &D;c                 p    | j                  t        j                  |j                               d   | _        y)av  Adds a virtual authenticator with the given options.

        Example:
            ```
            from selenium.webdriver.common.virtual_authenticator import VirtualAuthenticatorOptions

            options = VirtualAuthenticatorOptions(protocol="u2f", transport="usb", device_id="myDevice123")
            driver.add_virtual_authenticator(options)
            ```
        r   N)r   r%   ADD_VIRTUAL_AUTHENTICATORr  r   )r   rc   s     r8   add_virtual_authenticatorz#WebDriver.add_virtual_authenticator"  s-     "&g.O.OQXQ`Q`Qb!cdk!lr7   c                     | j                   S )z,Returns the id of the virtual authenticator.)r   r   s    r8   virtual_authenticator_idz"WebDriver.virtual_authenticator_id/  s     %%%r7   c                 j    | j                  t        j                  d| j                  i       d| _        y)zRemoves a previously added virtual authenticator.

        The authenticator is no longer valid after removal, so no
        methods may be called.
        authenticatorIdN)r   r%   REMOVE_VIRTUAL_AUTHENTICATORr   r   s    r8   remove_virtual_authenticatorz&WebDriver.remove_virtual_authenticator4  s,     	W99<MtOeOe;fg!%r7   
credentialc                     | j                  t        j                  i |j                         d| j                  i       y)a/  Injects a credential into the authenticator.

        Example:
            ```
            from selenium.webdriver.common.credential import Credential

            credential = Credential(id="user@example.com", password="aPassword")
            driver.add_credential(credential)
            ```
        r  N)r   r%   ADD_CREDENTIALr  r   )r   r  s     r8   add_credentialzWebDriver.add_credential>  s6     	W++-p
0B0B0D-pFWY]YoYo-pqr7   c                     | j                  t        j                  d| j                  i      }|d   D cg c]  }t	        j
                  |       c}S c c}w )z;Returns the list of credentials owned by the authenticator.r  r   )r   r%   GET_CREDENTIALSr   r    	from_dict)r   credential_datar  s      r8   get_credentialszWebDriver.get_credentialsL  sL     ,,w'>'>ARTXTjTj@klCRSZC[\Z
$$Z0\\\s   Acredential_idc                     t        |t              rt        |      j                         }| j	                  t
        j                  || j                  d       y)zRemoves a credential from the authenticator.

        Example:
            `credential_id = "user@example.com"`
            `driver.remove_credential(credential_id)`
        )credentialIdr  N)rX   	bytearrayr   rr  r   r%   REMOVE_CREDENTIALr   )r   r  s     r8   remove_credentialzWebDriver.remove_credentialR  sD     mY/-m<CCEM%%Z^ZpZp'q	
r7   c                 \    | j                  t        j                  d| j                  i       y)z/Removes all credentials from the authenticator.r  N)r   r%   REMOVE_ALL_CREDENTIALSr   r   s    r8   remove_all_credentialsz WebDriver.remove_all_credentialsb  s$     	W336GI_I_5`ar7   verifiedc                 ^    | j                  t        j                  | j                  |d       y)a  Set whether the authenticator will simulate success or failure on user verification.

        Args:
            verified: True if the authenticator will pass user verification,
                False otherwise.

        Example:
            `driver.set_user_verified(True)`
        )r  isUserVerifiedN)r   r%   SET_USER_VERIFIEDr   )r   r  s     r8   set_user_verifiedzWebDriver.set_user_verifiedg  s$     	W..DDZDZnv0wxr7   c                 ~    d| j                   vrt        d      | j                  t        j                        d   d   S )z9Retrieves the downloadable files as a list of file names.se:downloadsEnabledCYou must enable downloads in order to work with downloadable files.r   names)r;   r   r   r%   GET_DOWNLOADABLE_FILESr   s    r8   get_downloadable_filesz WebDriver.get_downloadable_filest  s;     (9(99$%jkk||G::;GDWMMr7   	file_nametarget_directoryc                    d| j                   vrt        d      t        j                  j	                  |      st        j
                  |       | j                  t        j                  d|i      d   d   }t        j                         5 }t        j                  j                  ||dz         }t        |d      5 }|j                  t        j                  |             ddd       t!        j"                  |d	      5 }|j%                  |       ddd       ddd       y# 1 sw Y   BxY w# 1 sw Y   xY w# 1 sw Y   yxY w)
aE  Download a file with the specified file name to the target directory.

        Args:
            file_name: The name of the file to download.
            target_directory: The path to the directory to save the downloaded file.

        Example:
            `driver.download_file("example.zip", "/path/to/directory")`
        r   r!  r   r   contentsz.zipr}  Nr)r;   r   ospathexistsmakedirsr   r%   DOWNLOAD_FILEtempfileTemporaryDirectoryrm  r  r  base64r   zipfileZipFile
extractall)r   r%  r&  r(  tmp_dirzip_filefilezip_refs           r8   download_filezWebDriver.download_file{  s    !(9(99$%jkkww~~./KK()<< 5 5	7JKGTU_`((* 	5gww||GY-?@Hh% 7

6++H567 3/ 57""#345	5 	57 75 5	5 	5s<   
0D8:%D D8=D,D8 D)	%D8,D5	1D88Ec                 t    d| j                   vrt        d      | j                  t        j                         y)zDeletes all downloadable files.r   r!  N)r;   r   r   r%   DELETE_DOWNLOADABLE_FILESr   s    r8   delete_downloadable_filesz#WebDriver.delete_downloadable_files  s.     (9(99$%jkkW667r7   c                     | j                   S )al  Get the Federated Credential Management (FedCM) dialog commands.

        Returns:
            An object providing access to all Federated Credential Management
            (FedCM) dialog commands.

        Examples:
            `driver.fedcm.title`
            `driver.fedcm.subtitle`
            `driver.fedcm.dialog_type`
            `driver.fedcm.account_list`
            `driver.fedcm.select_account(0)`
            `driver.fedcm.accept()`
            `driver.fedcm.dismiss()`
            `driver.fedcm.enable_delay()`
            `driver.fedcm.disable_delay()`
            `driver.fedcm.reset_cooldown()`
        )r   r   s    r8   fedcmzWebDriver.fedcm  s    ( {{r7   c                 V    | j                   j                  t        j                  d      S )z8Returns whether the browser supports FedCM capabilities.F)r;   rS   r   FEDCM_CAPABILITYr   s    r8   supports_fedcmzWebDriver.supports_fedcm  s#       $$Z%@%@%HHr7   c                 2    | j                   st        d      y)z.Raises an exception if FedCM is not supported.znThis browser does not support Federated Credential Management. Please ensure you're using a supported browser.N)rA  r   r   s    r8   _require_fedcm_supportz WebDriver._require_fedcm_support  s#    ""$B  #r7   c                 8    | j                          t        |       S )z0Returns the FedCM dialog object for interaction.)rC  r   r   s    r8   dialogzWebDriver.dialog  s     	##%d|r7   c                      ddl m ddlm}  j	                          |f}dt
        dz  f fd | |||      }|j                  fd      S )	a  Waits for and returns the FedCM dialog.

        Args:
            timeout: How long to wait for the dialog.
            poll_frequency: How frequently to poll.
            ignored_exceptions: Exceptions to ignore while waiting.

        Returns:
            The FedCM dialog object if found.

        Raises:
            TimeoutException: If dialog doesn't appear.
            WebDriverException: If FedCM not supported.
        r   )NoAlertPresentException)WebDriverWaitNr3   c                  R    	 t              } | j                  r| S d S # $ r Y y w xY wr   )r   r   )rE  rG  r   s    r8   _check_fedcmz,WebDriver.fedcm_dialog.<locals>._check_fedcm  s4    !'v6$6* s     &&)poll_frequencyignored_exceptionsc                             S r   r6   )r_  rJ  s    r8   <lambda>z(WebDriver.fedcm_dialog.<locals>.<lambda>  s	    LN r7   )selenium.common.exceptionsrG  selenium.webdriver.support.waitrH  rC  r   until)r   timeoutrK  rL  rH  waitrG  rJ  s   `     @@r8   fedcm_dialogzWebDriver.fedcm_dialog  sZ     	GA##%%"9!;	ftm 	 T7>^pqzz233r7   )zhttp://127.0.0.1:4444TNNNNN)r3   r   r3   Nr   )r  )NNNN)   g      ?N)ry   rz   r{   r|   r0   r   r.   r   rY   r,   boolr(   r   r   r*   r   r$   r   r   r   BaseExceptiontypesTracebackTyper   r   r   propertyr+   r   r   r   r   r   r   r   r   r   r   r	   r   rS   r   r-   r   r   r   r   r   r  r  r	  r   r  r  r  r  r  r   r   r/   r"  r%  r)  r,  r/  r8  r;  r>  rG  rO  rQ  rS  rW  r   r\  setterr   IDri  re  r;   r  r  r   r  r  r  r  r  r  r  r  r  r   r  tupler1   r  r   r  r   r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   r  r   r  r  r!   r  r  r"   r  r    r  r  r  r  r  r  r$  r9  r<  r'   r>  rA  rC  r   rE  rT  r6   r7   r8   r   r      s9    " O 4K-1:>5937-1I* 00I* I* $d*	I*
 tK0047I* ,d2I* j)D0I* $d*I* 
I*V`# `}%, T! &&-	 3 3<    Lc L L$ 4  7S 7Z 7\3 \$ \(Kc K4S>D3H KTXY\^aYaTb K80s 0t 0 	@s 	@ 	@# #) #	k	 	kd 	k)DI )ZS Z2Z3 Z$ Z& >S > > >S > >$ Ls L L ES	 E E$
0.
Bt(; 
Bs 
B 8  &&)&>T$Z >$+ (<1F*ZE Zd ZXu X Xh% hD h" $( $ $$ __M M !ee ZC$J Z* Z4  "uu$ aS4Z a4
CS a> d  $ :54 5Ju J9# 9C3 Ct C9C 9 98U 8u 8C 8X\ 8	4T 	4ks kt k
	> 	>r$ r" #| # # ' ' ET E E g g:c+>&> ? :> = =,   

      ( "' " " &/ & &(   0 ![ ! !, "l " "& 9  , u  .&6m1L mQU m &#* & & $& $& $r r r $r $]j!1 ] $]
 $
sY 
4 
 $
 $b $b $
y$ 
y4 
y $
yN N5s 5c 5d 548 u  * I I I   
4r7   r   rU  r   )hr|   r1  r4  r>   r*  ro  r/  rY  r  r2  abcr   r   r   r   r   	importlibr   typingr	   r
   rO  r   r   r   r   r   &selenium.webdriver.common.bidi.browserr   /selenium.webdriver.common.bidi.browsing_contextr   (selenium.webdriver.common.bidi.emulationr   $selenium.webdriver.common.bidi.inputr   &selenium.webdriver.common.bidi.networkr   *selenium.webdriver.common.bidi.permissionsr   %selenium.webdriver.common.bidi.scriptr   &selenium.webdriver.common.bidi.sessionr   &selenium.webdriver.common.bidi.storager   +selenium.webdriver.common.bidi.webextensionr   selenium.webdriver.common.byr   &selenium.webdriver.common.fedcm.dialogr   !selenium.webdriver.common.optionsr   r   ,selenium.webdriver.common.print_page_optionsr   "selenium.webdriver.common.timeoutsr   /selenium.webdriver.common.virtual_authenticatorr    r!   r"   )selenium.webdriver.remote.bidi_connectionr#   'selenium.webdriver.remote.client_configr$   !selenium.webdriver.remote.commandr%   &selenium.webdriver.remote.errorhandlerr&   selenium.webdriver.remote.fedcmr'   'selenium.webdriver.remote.file_detectorr(   r)   +selenium.webdriver.remote.locator_converterr*    selenium.webdriver.remote.mobiler+   +selenium.webdriver.remote.remote_connectionr,   $selenium.webdriver.remote.script_keyr-   $selenium.webdriver.remote.shadowrootr.   #selenium.webdriver.remote.switch_tor/   $selenium.webdriver.remote.webelementr0   .selenium.webdriver.remote.websocket_connectionr1   +selenium.webdriver.support.relative_locatorr2   r5   r9   r   rE   rY   rW  rb   r   rv   rx   r   r6   r7   r8   <module>r     sA  $ $    	       / : #   ; K > 6 : B 8 : : D + 9 E E 7 
 E @ 5 ? 1 S H 3 H : ; 8 ; N B
BO$ O0 *.,,  	
  $& @D- $ Dg p4 p4r7   