
    hg                     d    d dl mZ ddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ  G d d          Zd	S )
   )Command    )NoSuchElementExceptionNoSuchFrameExceptionNoSuchWindowException)Alert)By)
WebElementc                   |    e Zd Zd Zedefd            Zedefd            ZddZ	ddZ
dddZdd	Zdd
Zd ZdS )SwitchToc                 B    dd l }|                    |          | _        d S )Nr   )weakrefproxy_driver)selfdriverr   s      \/var/www/fb-scrape/myenv/lib/python3.11/site-packages/selenium/webdriver/remote/switch_to.py__init__zSwitchTo.__init__   s"    }}V,,    returnc                 V    | j                             t          j                  d         S )z
        Returns the element with focus, or BODY if nothing has focus.

        :Usage:
            ::

                element = driver.switch_to.active_element
        value)r   executer   W3C_GET_ACTIVE_ELEMENTr   s    r   active_elementzSwitchTo.active_element!   s"     |##G$BCCGLLr   c                 <    t          | j                  }|j         |S )z
        Switches focus to an alert on the page.

        :Usage:
            ::

                alert = driver.switch_to.alert
        )r   r   text)r   alerts     r   r   zSwitchTo.alert-   s     dl##

r   Nc                 T    | j                             t          j        ddi           dS )z
        Switch focus to the default frame.

        :Usage:
            ::

                driver.switch_to.default_content()
        idN)r   r   r   SWITCH_TO_FRAMEr   s    r   default_contentzSwitchTo.default_content;   s)     	W4tTlCCCCCr   c                 t   t          |t                    r{	 | j                            t          j        |          }nT# t          $ rG 	 | j                            t          j        |          }n# t          $ r t          |          w xY wY nw xY w| j        	                    t          j        d|i           dS )a  
        Switches focus to the specified frame, by index, name, or webelement.

        :Args:
         - frame_reference: The name of the window to switch to, an integer representing the index,
                            or a webelement that is an (i)frame to switch to.

        :Usage:
            ::

                driver.switch_to.frame('frame_name')
                driver.switch_to.frame(1)
                driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0])
        r!   N)
isinstancestrr   find_elementr	   IDr   NAMEr   r   r   r"   )r   frame_references     r   framezSwitchTo.frameF   s     os++ 	@@"&,";";BE?"S"S) @ @ @@&*l&?&?&Y&YOO- @ @ @.???@ $O@ 	W4t_6MNNNNNs'   %= 
B%A.-B.BBBc                     | j                             t          j        d|i          d         }|                     |d                    dS )a  Switches to a new top-level browsing context.

        The type hint can be one of "tab" or "window". If not specified the
        browser will automatically select it.

        :Usage:
            ::

                driver.switch_to.new_window('tab')
        typer   handleN)r   r   r   
NEW_WINDOW_w3c_window)r   	type_hintr   s      r   
new_windowzSwitchTo.new_window`   sF     $$W%7&)9LMMgVx)))))r   c                 N    | j                             t          j                   dS )z
        Switches focus to the parent context. If the current context is the top
        level browsing context, the context remains unchanged.

        :Usage:
            ::

                driver.switch_to.parent_frame()
        N)r   r   r   SWITCH_TO_PARENT_FRAMEr   s    r   parent_framezSwitchTo.parent_framen   s#     	W;<<<<<r   c                 0    |                      |           dS )z
        Switches focus to the specified window.

        :Args:
         - window_name: The name or window handle of the window to switch to.

        :Usage:
            ::

                driver.switch_to.window('main')
        N)r0   )r   window_names     r   windowzSwitchTo.windowz   s     	%%%r   c                      fd}	  ||           d S # t           $ ra} j        j        } j        j        }|D ]4} ||            j                            d          }||k    r Y d }~d S 5 ||           |d }~ww xY w)Nc                 V    j                             t          j        d| i           d S )Nr.   )r   r   r   SWITCH_TO_WINDOW)hr   s    r   send_handlez)SwitchTo._w3c_window.<locals>.send_handle   s(    L  !9Ha=IIIIIr   zreturn window.name)r   r   current_window_handlewindow_handlesexecute_script)r   r7   r=   eoriginal_handlehandlesr.   current_names   `       r   r0   zSwitchTo._w3c_window   s    	J 	J 	J 	J 	J	K$$$$$$ 
	 
	 
	"l@Ol1G!  F####|::;OPP,..FFFFFF /K(((G
	s    
B AA;-A;;B )r   N)N)__name__
__module____qualname__r   propertyr
   r   r   r   r#   r+   r2   r5   r8   r0    r   r   r   r      s        - - - 	M
 	M 	M 	M X	M u    X	D 	D 	D 	DO O O O4* * * * *
= 
= 
= 
=       r   r   N)commandr   selenium.common.exceptionsr   r   r   selenium.webdriver.common.alertr   selenium.webdriver.common.byr	   $selenium.webdriver.remote.webelementr
   r   rI   r   r   <module>rO      s   $      ? ? ? ? ? ? ? ? ? ? 2 1 1 1 1 1 + + + + + + ; ; ; ; ; ;~ ~ ~ ~ ~ ~ ~ ~ ~ ~r   