B
     ¸h  ã               @   s0   d Z ddlmZ ddlmZ G dd„ deƒZdS )z
The Alert implementation.
é    )Úkeys_to_typing)ÚCommandc               @   s<   e Zd ZdZdd„ Zedd„ ƒZdd„ Zdd	„ Zd
d„ Z	dS )ÚAlertak  
    Allows to work with alerts.

    Use this class to interact with alert prompts.  It contains methods for dismissing,
    accepting, inputting, and getting text from alert prompts.

    Accepting / Dismissing alert prompts::

        Alert(driver).accept()
        Alert(driver).dismiss()

    Inputting a value into an alert prompt:

        name_prompt = Alert(driver)
        name_prompt.send_keys("Willian Shakesphere")
        name_prompt.accept()


    Reading a the text of a prompt for verification:

        alert_text = Alert(driver).text
        self.assertEqual("Do you wish to quit?", alert_text)

    c             C   s
   || _ dS )z}
        Creates a new Alert.

        :Args:
         - driver: The WebDriver instance which performs user actions.
        N)Údriver)Úselfr   © r   ú\C:\Users\sanjo\AppData\Local\Qlobot\Launcher\ext_packages\selenium\webdriver\common\alert.pyÚ__init__4   s    zAlert.__init__c             C   s0   | j jr| j  tj¡d S | j  tj¡d S dS )z-
        Gets the text of the Alert.
        ÚvalueN)r   Úw3cÚexecuter   ÚW3C_GET_ALERT_TEXTÚGET_ALERT_TEXT)r   r   r   r   Útext=   s    z
Alert.textc             C   s*   | j jr| j  tj¡ n| j  tj¡ dS )z0
        Dismisses the alert available.
        N)r   r   r   r   ÚW3C_DISMISS_ALERTÚDISMISS_ALERT)r   r   r   r   ÚdismissG   s    zAlert.dismissc             C   s*   | j jr| j  tj¡ n| j  tj¡ dS )zx
        Accepts the alert available.

        Usage::
        Alert(driver).accept() # Confirm a alert dialog.
        N)r   r   r   r   ÚW3C_ACCEPT_ALERTÚACCEPT_ALERT)r   r   r   r   ÚacceptP   s    zAlert.acceptc             C   s<   | j jr$| j  tjt|ƒ|dœ¡ n| j  tjd|i¡ dS )zp
        Send Keys to the Alert.

        :Args:
         - keysToSend: The text to be sent to Alert.


        )r
   r   r   N)r   r   r   r   ÚW3C_SET_ALERT_VALUEr   ÚSET_ALERT_VALUE)r   Z
keysToSendr   r   r   Ú	send_keys\   s    	zAlert.send_keysN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   Úpropertyr   r   r   r   r   r   r   r   r      s   	
	r   N)r   Úselenium.webdriver.common.utilsr   Z!selenium.webdriver.remote.commandr   Úobjectr   r   r   r   r   Ú<module>   s   