selenium.webdriver.common.log#
Functions
Classes
|
Class for accessing logging APIs using the WebDriver Bidi protocol. |
- class Log(driver, bidi_session)[source]#
Bases:
objectClass for accessing logging APIs using the WebDriver Bidi protocol.
This class is not to be used directly and should be used from the webdriver base classes.
- mutation_events()[source]#
Listen for mutation events and emit them as they are found.
Deprecated since version Use:
driver.script.add_dom_mutation_handler()instead, which uses the WebDriver BiDi protocol.Example
- 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;”
- Return type:
AsyncGenerator[dict[str, Any], None]
- add_js_error_listener()[source]#
Listen for JS errors and check if they occurred when the context manager exits.
Deprecated since version Use:
driver.script.add_javascript_error_handler()instead, which uses the WebDriver BiDi protocol.Example
- 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”
- Return type:
AsyncGenerator[dict[str, Any], None]
- add_listener(event_type)[source]#
Listen for certain events that are passed in.
Deprecated since version Use:
driver.script.add_console_message_handler()instead, which uses the WebDriver BiDi protocol.- Parameters:
event_type – The type of event that we want to look at.
- Return type:
AsyncGenerator[dict[str, Any], None]
Example
- async with driver.log.add_listener(Console.log) as messages:
driver.execute_script(“console.log(‘I like cheese’)”)
assert messages[“message”] == “I love cheese”