
    hg                     f    d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ da	d Z
 G d d          ZdS )    N)asynccontextmanager)import_module)Byc                  6    t           st          d          a d S d S )Nz"selenium.webdriver.common.bidi.cdp)cdpr        V/var/www/fb-scrape/myenv/lib/python3.11/site-packages/selenium/webdriver/common/log.py
import_cdpr      s)     B@AAB Br	   c                   h    e Zd ZdZddZedefd            Zed             Zedefd            Z	dS )	Logz
        This class allows access to logging APIs that use the new WebDriver Bidi
        protocol.

        This class is not to be used directly and should be used from the webdriver
        base classes.
    returnNc                 h   t           j        dk    sJ || _        |j        | _        |j        | _        |j        | _        d                    t                              d          d d                   }t          j
        |d                              d                                          | _        d S )N      .zmutation-listener.jsutf8)sysversion_infodriversessionr   devtoolsjoin__name__splitpkgutilget_datadecodestrip_mutation_listener_js)selfr   bidi_session_pkgs       r
   __init__zLog.__init__-   s    6))))#+#$-xxs++CRC011%,%5d<R%S%S%Z%Z[a%b%b%h%h%j%j"""r	   c                  K   t           j        dk    sJ | j                            d          }|                    | j        j                                                   d{V  | j                            d          }|                    | j        j                                                   d{V  |                    | j        j        	                    d                     d{V  | j
                            | j                   |                    | j        j                            | j                             d{V }| j
                            | j        |           | j
                            d| j                    i }|                    | j        j        j                  4 d{V }|W V  ddd          d{V  n# 1 d{V swxY w Y   t#          j        |j        j                  }| j
                            t,          j        d|d                    }|s|                    d           |d	         |d
<   |d         |d<   |d         |d<   |d         |d<   dS )aQ  
        Listens for mutation events and emits them as it finds them

        :Usage:
             ::
               async with driver.log.mutation_events() as event:
                    pages.load("dynamic.html")
                    driver.find_element(By.ID, "reveal").click()
                    WebDriverWait(driver, 5)                        .until(EC.visibility_of(driver.find_element(By.ID, "revealed")))

                assert event["attribute_name"] == "style"
                assert event["current_value"] == ""
                assert event["old_value"] == "display:none;"

        r   page.enableNruntime.enable__webdriver_attributezreturn z*[data-__webdriver_id=targetr   elementnameattribute_namevaluecurrent_valueoldValue	old_value)r   r   r   get_session_contextexecuter   pageenableruntimeadd_bindingr   
pin_scriptr"   &add_script_to_evaluate_on_new_documentexecute_scriptwait_forBindingCalledjsonloadsr/   payloadfind_elementsr   CSS_SELECTORappend)r#   r5   r7   
script_keyeventevntr@   elementss           r
   mutation_eventszLog.mutation_events6   s     & 6))))x++M::ll4=-4466777777777(../?@@oodm3::<<=========oodm3??@WXXYYYYYYYYYt9:::<<(:(a(abfb|(}(}~~~~~~~~
t9:FFF""#IT-G#I#IJJJ##DM$9$GHH 	 	 	 	 	 	 	DKKKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 *TZ/00222?Dp]dem]nDpDpqq 	"OOD!!!#A;i")&/!(!1o$Z0ks   9G
GGc                x  K   | j                             d          }|                    | j        j                                                   d{V  | j                             d          }|                    | j        j                                                   d{V  | j        j                            dd          }|                    | j        j        j                  4 d{V }|W V  ddd          d{V  n# 1 d{V swxY w Y   |j	        j
        |_
        |j	        j        |_        dS )a  
        Listens for JS errors and when the contextmanager exits check if there were JS Errors

        :Usage:
             ::

                async with driver.log.add_js_error_listener() as error:
                    driver.find_element(By.ID, "throwing-mouseover").click()
                assert bool(error)
                assert error.exception_details.stack_trace.call_frames[0].function_name == "onmouseover"
        r(   Nr)   )r   r3   r4   r   r5   r6   r7   ExceptionThrownr<   r/   	timestampexception_details)r#   r   js_exception	exceptions       r
   add_js_error_listenerzLog.add_js_error_listenera   s      (..}==oodm07799:::::::::(../?@@oodm3::<<=========},<<T4HH##DM$9$IJJ 	 	 	 	 	 	 	i	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	!*!:)2)J&&&s   /D
DDc                
  K   ddl m} | j                            d          }|                    | j        j                                                   d{V  | j                            d          }|                    | j        j                                                   d{V  ddd}|	                    | j        j        j
                  4 d{V }|W V  ddd          d{V  n# 1 d{V swxY w Y   ||j        k    r4|j        j        d         j        |d<   |j        j        d         j        |d<   ||j        k    r6|j        j        d         j        |d<   |j        j        d         j        |d<   dS dS )	a  
        Listens for certain events that are passed in.

        :Args:
         - event_type: The type of event that we want to look at.

         :Usage:
             ::

                async with driver.log.add_listener(Console.log) as messages:
                    driver.execute_script("console.log('I like cheese')")
                assert messages["message"] == "I love cheese"

        r   )Consoler(   Nr)   )messagelevelrR   rS   )&selenium.webdriver.common.bidi.consolerQ   r   r3   r4   r   r5   r6   r7   r<   ConsoleAPICalledERRORr/   argstype_ALL)r#   
event_typerQ   r   consolemessagess         r
   add_listenerzLog.add_listenery   s     " 	CBBBBB(..}==oodm07799:::::::::(../?@@oodm3::<<=========
 
 ##DM$9$JKK 	 	 	 	 	 	 	xMMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 &&!)!4Q!7!=GI'~215;GG$$!)!4Q!7!=GI'~215;GG %$s   C22
C<?C<)r   N)
r   
__module____qualname____doc__r&   r   dictrH   rO   r]   r   r	   r
   r   r   $   s         k k k k (1t (1 (1 (1 (1T K K K. !< !< !< !< !< !< !<r	   r   )r>   r   r   
contextlibr   	importlibr   selenium.webdriver.common.byr   r   r   r   r   r	   r
   <module>re      s   $   



 * * * * * * # # # # # # + + + + + +
B B Bw< w< w< w< w< w< w< w< w< w<r	   