o
    Vh;+                     @   s   d dl 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 de
eZG d	d
 d
ZG dd dZG dd dZG dd dZG dd dZG dd dedZG dd deZdS )    N)ABCMeta)abstractmethod)Enum)InvalidArgumentException)Proxyc                   @   s   e Zd ZdZdZdZdZdS )PageLoadStrategya  Enum of possible page load strategies.

    Selenium support following strategies:
        * normal (default) - waits for all resources to download
        * eager - DOM access is ready, but other resources like images may still be loading
        * none - does not block `WebDriver` at all

    Docs: https://www.selenium.dev/documentation/webdriver/drivers/options/#pageloadstrategy.
    normaleagernoneN)__name__
__module____qualname____doc__r   r	   r
    r   r   ^/home/air/yokohama/back/venv/lib/python3.10/site-packages/selenium/webdriver/common/options.pyr      s
    
r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )_BaseOptionsDescriptorc                 C   
   || _ d S Nnameselfr   r   r   r   __init__+      
z_BaseOptionsDescriptor.__init__c                 C   s(   | j dv r|j| j dS |j| j S )N)acceptInsecureCertsstrictFileInteractabilitysetWindowRectse:downloadsEnabledF)r   _capsgetr   objclsr   r   r   __get__.   s   
z_BaseOptionsDescriptor.__get__c                 C   s   | | j| d S r   )set_capabilityr   r   r!   valuer   r   r   __set__3   s   z_BaseOptionsDescriptor.__set__N)r   r   r   r   r#   r'   r   r   r   r   r   *   s    r   c                   @   (   e Zd ZdZdd Zdd Zdd ZdS )	_PageLoadStrategyDescriptorzDetermines the point at which a navigation command is returned:
    https://w3c.github.io/webdriver/#dfn-table-of-page-load-strategies.

    :param strategy: the strategy corresponding to a document readiness state
    c                 C   r   r   r   r   r   r   r   r   >   r   z$_PageLoadStrategyDescriptor.__init__c                 C      |j | jS r   r   r   r   r    r   r   r   r#   A      z#_PageLoadStrategyDescriptor.__get__c                 C   "   |dv r| | j| d S td)N)r   r	   r
   z>Strategy can only be one of the following: normal, eager, noner$   r   
ValueErrorr%   r   r   r   r'   D   s   z#_PageLoadStrategyDescriptor.__set__Nr   r   r   r   r   r#   r'   r   r   r   r   r)   7   s
    r)   c                   @   r(   )	"_UnHandledPromptBehaviorDescriptorad  How the driver should respond when an alert is present and the:
    command sent is not handling the alert:
    https://w3c.github.io/webdriver/#dfn-table-of-page-load-strategies:

    :param behavior: behavior to use when an alert is encountered

    :returns: Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)
    c                 C   r   r   r   r   r   r   r   r   U   r   z+_UnHandledPromptBehaviorDescriptor.__init__c                 C   r*   r   r+   r    r   r   r   r#   X   r,   z*_UnHandledPromptBehaviorDescriptor.__get__c                 C   r-   )N)dismissacceptzdismiss and notifyzaccept and notifyignoreziBehavior can only be one of the following: dismiss, accept, dismiss and notify, accept and notify, ignorer.   r%   r   r   r   r'   [   s
   z*_UnHandledPromptBehaviorDescriptor.__set__Nr0   r   r   r   r   r1   K   s
    	r1   c                   @   r(   )	_TimeoutsDescriptoraL  How long the driver should wait for actions to complete before:
    returning an error https://w3c.github.io/webdriver/#timeouts:

    :param timeouts: values in milliseconds for implicit wait, page load and script timeout

    :returns: Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)
    c                 C   r   r   r   r   r   r   r   r   n   r   z_TimeoutsDescriptor.__init__c                 C   r*   r   r+   r    r   r   r   r#   q   r,   z_TimeoutsDescriptor.__get__c                 C   s0   t dd | D r|| j| d S td)Nc                 s   s    | ]}|d v V  qdS ))implicitpageLoadscriptNr   ).0xr   r   r   	<genexpr>u   s    z._TimeoutsDescriptor.__set__.<locals>.<genexpr>zITimeout keys can only be one of the following: implicit, pageLoad, script)allkeysr$   r   r/   r%   r   r   r   r'   t   s   z_TimeoutsDescriptor.__set__Nr0   r   r   r   r   r5   e   s
    r5   c                   @   r(   )	_ProxyDescriptorz':Returns: Proxy if set, otherwise None.c                 C   r   r   r   r   r   r   r   r   ~   r   z_ProxyDescriptor.__init__c                 C   s   |j S r   )_proxyr    r   r   r   r#         z_ProxyDescriptor.__get__c                 C   s,   t |ts	td||_| |j| j< d S )Nz$Only Proxy objects can be passed in.)
isinstancer   r   r?   to_capabilitiesr   r   r%   r   r   r   r'      s   
z_ProxyDescriptor.__set__Nr0   r   r   r   r   r>   {   s
    r>   c                	       s   e Zd ZdZedZ	 edZ	 edZ	 edZ	 edZ		 e
dZ	 edZ	 ed	Z	 ed
Z	 edZ	 d fddZedd ZdddZ			ddeje deje deje ddfddZedd Zeedd Z  ZS )BaseOptionsz*Base class for individual browser options.browserVersionplatformNamer   r   r   pageLoadStrategyunhandledPromptBehaviortimeoutsproxyr   returnNc                    s0   t    | j| _d | _| dtj d | _d S )NrF   )	superr   default_capabilitiesr   r?   r$   r   r   mobile_optionsr   	__class__r   r   r   l  s
   

zBaseOptions.__init__c                 C      | j S r   r   rN   r   r   r   capabilitiess  s   zBaseOptions.capabilitiesc                 C   s   || j |< dS )zSets a capability.NrR   )r   r   r&   r   r   r   r$   w  s   zBaseOptions.set_capabilityandroid_packageandroid_activitydevice_serialc                 C   s:   |st dd|i| _|r|| jd< |r|| jd< dS dS )zEnables mobile browser use for browsers that support it.

        :Args:
            android_activity: The name of the android package to start
        z!android_package must be passed inandroidPackageandroidActivityandroidDeviceSerialN)AttributeErrorrM   )r   rT   rU   rV   r   r   r   enable_mobile{  s   

zBaseOptions.enable_mobilec                 C      dS )z-Convert options into capabilities dictionary.Nr   rN   r   r   r   rB         zBaseOptions.to_capabilitiesc                 C   r\   )z6Return minimal capabilities necessary as a dictionary.Nr   rN   r   r   r   rL     r]   z BaseOptions.default_capabilitiesrJ   N)NNN)r   r   r   r   r   browser_versionplatform_nameaccept_insecure_certsstrict_file_interactabilityset_window_rectr)   page_load_strategyr1   unhandled_prompt_behaviorr5   rH   r>   rI   enable_downloadsr   propertyrS   r$   typingOptionalstrr[   r   rB   rL   __classcell__r   r   rO   r   rC      sV    



rC   )	metaclassc                       sV   e Zd ZdZd fddZedd Zddd	Zdd
dZdd Z	edd Z
  ZS )
ArgOptionsz Binary Location Must be a StringrJ   Nc                    s   t    g | _d| _d S )NF)rK   r   
_arguments_ignore_local_proxyrN   rO   r   r   r     s   

zArgOptions.__init__c                 C   rQ   )z5:Returns: A list of arguments needed for the browser.)rn   rN   r   r   r   	arguments  s   zArgOptions.argumentsc                 C   s   |r
| j | dS td)zTAdds an argument to the list.

        :Args:
         - Sets the arguments
        zargument can not be nullN)rn   appendr/   )r   argumentr   r   r   add_argument  s   zArgOptions.add_argumentc                 C   s
   d| _ dS )zaBy calling this you will ignore HTTP_PROXY and HTTPS_PROXY from
        being picked up and used.TN)ro   rN   r   r   r   (ignore_local_proxy_environment_variables  s   
z3ArgOptions.ignore_local_proxy_environment_variablesc                 C   rQ   r   rR   rN   r   r   r   rB     r@   zArgOptions.to_capabilitiesc                 C   s   i S r   r   rN   r   r   r   rL     s   zArgOptions.default_capabilitiesr^   )r   r   r   BINARY_LOCATION_ERRORr   rg   rp   rs   rt   rB   rL   rk   r   r   rO   r   rm     s    


rm   )rh   abcr   r   enumr   selenium.common.exceptionsr   selenium.webdriver.common.proxyr   rj   r   r   r)   r1   r5   r>   rC   rm   r   r   r   r   <module>   s      