selenium.webdriver.common.log

Functions

import_cdp()

Classes

Log(driver, bidi_session)

Class for accessing logging APIs using the WebDriver Bidi protocol.

selenium.webdriver.common.log.import_cdp()[source]
class selenium.webdriver.common.log.Log(driver, bidi_session)[source]

Class 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() AsyncGenerator[dict[str, Any], None][source]

Listen for mutation events and emit them as they are found.

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;”

add_js_error_listener() AsyncGenerator[dict[str, Any], None][source]

Listen for JS errors and check if they occurred when the context manager exits.

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”

add_listener(event_type) AsyncGenerator[dict[str, Any], None][source]

Listen for certain events that are passed in.

Args:

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

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”