
    /_i'                     \    d dl 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  G d d      Zy)	    )NoSuchElementExceptionNoSuchFrameExceptionNoSuchWindowException)Alert)By)Command)
WebElementc                       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z  ez  ddfdZdd	e
dz  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      b/var/www/html/land_sniper/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.

        Example:
            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 )zmSwitches focus to an alert on the page.

        Example:
            alert = driver.switch_to.alert
        )r   r   text)r   alert_s      r   r   zSwitchTo.alert)   s      dll#JJr   c                 \    | j                   j                  t        j                  ddi       y)zlSwitch focus to the default frame.

        Example:
            driver.switch_to.default_content()
        idN)r   r   r   SWITCH_TO_FRAMEr   s    r   default_contentzSwitchTo.default_content4   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  Switch focus to the specified frame by index, name, or element.

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

        Example:
                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.frame<   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)zSwitches 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.

        Example:
                driver.switch_to.new_window("tab")
        typer   handleN)r   r   r   
NEW_WINDOW_w3c_window)r   r-   r   s      r   
new_windowzSwitchTo.new_windowS   s<     $$W%7%7&)9LMgVx)r   c                 V    | j                   j                  t        j                         y)zSwitch focus to the parent browsing context.

        If the current context is already the top level browsing context, it remains unchanged.

        Example:
                driver.switch_to.parent_frame()
        N)r   r   r   SWITCH_TO_PARENT_FRAMEr   s    r   parent_framezSwitchTo.parent_frame_   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.

        Example:
            driver.switch_to.window("main")
        N)r2   )r   r7   s     r   windowzSwitchTo.windowi   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 )Nr0   )r   r   r   SWITCH_TO_WINDOW)hr   s    r   send_handlez)SwitchTo._w3c_window.<locals>.send_handleu   s!    LL  !9!9Ha=Ir   zreturn window.name)r   r   current_window_handlewindow_handlesexecute_script)r   r7   r>   original_handlehandlesr0   current_names   `      r   r2   zSwitchTo._w3c_windowt   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'   intr,   r3   r6   r9   r2    r   r   r   r      s    -
 M
 M M u  DOS3Y%; O O.
*C$J 
*$ 
*=	&# 	&$ 	&s t r   r   N)selenium.common.exceptionsr   r   r   selenium.webdriver.common.alertr   selenium.webdriver.common.byr   !selenium.webdriver.remote.commandr   $selenium.webdriver.remote.webelementr	   r   rJ   r   r   <module>rP      s&   & k j 1 + 5 ;k kr   