1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
U
[±dã@sRddlZddlZddlmZddlmZddlmZdadd„Z    Gdd„dƒZ
dS)    éN)Úasynccontextmanager)Ú import_module)ÚBycCsts tdƒadS)Nz"selenium.webdriver.common.bidi.cdp)Úcdpr©rrúTd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\selenium/webdriver/common/log.pyÚ
import_cdpsrc@sNeZdZdZddœdd„Zeedœdd„ƒZedd    „ƒZeedœd
d „ƒZ    dS) Ú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.
    N)ÚreturncCsR||_|j|_|j|_|j|_d t d¡dd…¡}t |d¡     d¡ 
¡|_ dS)NÚ.éÿÿÿÿzmutation-listener.jsÚutf8) ÚdriverÚsessionrÚdevtoolsÚjoinÚ__name__ÚsplitÚpkgutilÚget_dataÚdecodeÚstripÚ_mutation_listener_js)ÚselfrZ bidi_sessionZ_pkgrrrÚ__init__*s z Log.__init__c
CsP|j d¡}| |jj ¡¡IdH|j d¡}| |jj ¡¡IdH| |jj d¡¡IdH|j     |j
¡| |jj  |j
¡¡IdH}|j     |j
|¡|j  d|j
›¡i}|  |jjj¡4IdHš }|VW5QIdHRXt |jj¡}|j tjd|d›¡}|s| d¡|d|d    <|d
|d <|d |d <|d|d<dS)aHListen for mutation events and emit them as they are found.
 
        :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;"
        ú page.enableNúruntime.enableZ__webdriver_attributezreturn z*[data-__webdriver_id=ÚtargetrÚelementÚnameZattribute_nameÚvalueZ current_valueZoldValueÚ    old_value)rÚget_session_contextÚexecuterÚpageÚenableÚruntimeZ add_bindingrZ
pin_scriptrZ&add_script_to_evaluate_on_new_documentZexecute_scriptÚwait_forZ BindingCalledÚjsonÚloadsr ÚpayloadZ find_elementsrZ CSS_SELECTORÚappend)rr$r&Z
script_keyÚeventZevntr*ÚelementsrrrÚmutation_events2s,  ÿ
 
   zLog.mutation_eventsc
Cs |j d¡}| |jj ¡¡IdH|j d¡}| |jj ¡¡IdH|jj dd¡}| |jjj¡4IdHš }|VW5QIdHRX|j    j
|_
|j    j |_ dS)a©Listen 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"
        rNr) rr"r#rr$r%r&ZExceptionThrownr'r Ú    timestampZexception_details)rrZ js_exceptionÚ    exceptionrrrÚadd_js_error_listener\s  
zLog.add_js_error_listenerc
Csîddlm}|j d¡}| |jj ¡¡IdH|j d¡}| |jj ¡¡IdHdddœ}|     |jjj
¡4IdHš }|VW5QIdHRX||j kr¼|j j dj |d<|j j dj|d<||jkrê|j j dj |d<|j j dj|d<dS)    aListen 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)ÚConsolerNr)ÚmessageÚlevelr3r4)Z&selenium.webdriver.common.bidi.consoler2rr"r#rr$r%r&r'ZConsoleAPICalledÚERRORr ÚargsÚtype_ÚALL)rZ
event_typer2rÚconsoleÚmessagesrrrÚ add_listenerts   
 
 
zLog.add_listener)
rÚ
__module__Ú __qualname__Ú__doc__rrÚdictr.r1r;rrrrr    "s)
r    ) r(rÚ
contextlibrÚ    importlibrZselenium.webdriver.common.byrrrr    rrrrÚ<module>s