
    ,h%                         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y)    )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y)SwitchToreturnNc                 8    dd l }|j                  |      | _        y )Nr   )weakrefproxy_driver)selfdriverr   s      e/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/selenium/webdriver/remote/switch_to.py__init__zSwitchTo.__init__    s    }}V,    c                 Z    | j                   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$BCGLLr   c                 H    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      dll#JJr   c                 \    | j                   j                  t        j                  ddi       y)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44tTlCr   frame_referencec                    t        |t              r+	 | j                  j                  t        j
                  |      }| j                  j                  t        j                  d|i       y# t        $ rL 	 | j                  j                  t        j                  |      }n# t        $ r}t        |      |d}~ww xY wY w xY w)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"&,,";";BEE?"S 	W44t_6MN * II&*ll&?&?&YO- I.?SHI $Is5   *A) )	B>3*BB>	B8'B33B88B>=B>	type_hintc                     | j                   j                  t        j                  d|i      d   }| j	                  |d          y)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   s<     $$W%7%7&)9LMgVx)r   c                 V    | j                   j                  t        j                         y)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                 &    | j                  |       y)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}	  ||       y # t         $ rh  j                  j                  } j                  j                  }|D ]-  } ||        j                  j	                  d      }||k(  s, Y y   ||        w xY w)Nc                 ^    j                   j                  t        j                  d| i       y )Nr3   )r   r   r   SWITCH_TO_WINDOW)hr   s    r   send_handlez)SwitchTo._w3c_window.<locals>.send_handle   s!    LL  !9!9Ha=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	$$ 
	"ll@@Oll11G! F##||::;OP,.	
 (
	s    A"B4B7B)r   N)N)__name__
__module____qualname__r   propertyr
   r   r   r!   r&   r   r*   intr/   r   r6   r9   r<   r5    r   r   r   r      s    -
 M
 M M 
u 
 
DOU3Z+?%@ OT 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 + ; y yr   