
     f%                         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  G d d          ZdS )    )Optional)Union)NoSuchElementException)NoSuchFrameException)NoSuchWindowException)Alert)By)
WebElement   )Commandc                       e Zd ZddZedefd            Zedefd            ZddZ	de
eeef         ddfdZdd	ee         ddfd
ZddZdeddfdZdeddfdZdS )SwitchToreturnNc                 B    dd l }|                    |          | _        d S )Nr   )weakrefproxy_driver)selfdriverr   s      f/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/selenium/webdriver/remote/switch_to.py__init__zSwitchTo.__init__    s"    }}V,,    c                 V    | j                             t          j                  d         S )zReturns 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 )zSwitches focus to an alert on the page.

        :Usage:
            ::

                alert = driver.switch_to.alert
        )r   r   text)r   alert_s      r   r!   zSwitchTo.alert0   s     dl##Jr   c                 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   frame_referencec                 ~   t          |t                    r	 | j                            t          j        |          }nY# t          $ rL 	 | j                            t          j        |          }n"# t          $ r}t          |          |d}~w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])
        Nr$   )
isinstancestrr   find_elementr	   IDr   NAMEr   r   r   r%   )r   r'   excs      r   framezSwitchTo.frameG   s     os++ 	II"&,";";BE?"S"S) I I II&*l&?&?&Y&YOO- I I I.??SHI $OI 	W4t_6MNNNNNs3   %= 
B%A.-B.
B8BBBB	type_hintc                     | 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   r0   r   s      r   
new_windowzSwitchTo.new_windowa   sF     $$W%7&)9LMMgVx)))))r   c                 N    | j                             t          j                   dS )zSwitches 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_frameo   s#     	W;<<<<<r   window_namec                 0    |                      |           dS )zSwitches 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)r5   )r   r:   s     r   windowzSwitchTo.windowz   s     	%%%%%r   c                       fd}	  ||           d S # t           $ rY  j        j        } j        j        }|D ]1} ||            j                            d          }||k    r Y d S 2 ||            w xY w)Nc                 V    j                             t          j        d| i           d S )Nr3   )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   r:   rA   original_handlehandlesr3   current_names   `      r   r5   zSwitchTo._w3c_window   s    	J 	J 	J 	J 	J	K$$$$$$ 
	 
	 
	"l@Ol1G!  F####|::;OPP,..FFF /K(((
	s    AA8*A8)r   N)N)__name__
__module____qualname__r   propertyr
   r   r   r!   r&   r   r*   intr/   r   r6   r9   r<   r5    r   r   r   r      sJ       - - - -
 M
 M M M XM 
u 
 
 
 X
D D D DOU3Z+?%@ OT O O O O4* *HSM *T * * * *	= 	= 	= 	=&# &$ & & & &s t      r   r   N)typingr   r   selenium.common.exceptionsr   r   r   selenium.webdriver.common.alertr   selenium.webdriver.common.byr	   $selenium.webdriver.remote.webelementr
   commandr   r   rM   r   r   <module>rT      s   $             = = = = = = ; ; ; ; ; ; < < < < < < 1 1 1 1 1 1 + + + + + + ; ; ; ; ; ;      y y y y y y y y y yr   