CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-seleniumhq-selenium--selenium-devtools-v133

Java bindings for Chrome DevTools Protocol v133, enabling advanced browser automation capabilities through Selenium WebDriver.

Pending
Overview
Eval results
Files

events.mddocs/

Event Handling

The v133Events class provides comprehensive runtime event monitoring capabilities, enabling developers to listen for console API calls, JavaScript exceptions, and other runtime events in the browser.

Capabilities

v133Events Class

Main event handling class that extends the base Events functionality with v133-specific implementations.

/**
 * v133-specific event handling implementation
 * Extends Events<ConsoleAPICalled, ExceptionThrown> for type-safe event processing
 */
public class v133Events extends Events<ConsoleAPICalled, ExceptionThrown> {
    /**
     * Creates a new v133Events instance
     * @param devtools DevTools instance for communication with browser
     */
    public v133Events(DevTools devtools);
}

Runtime Control

Methods for enabling and disabling runtime event monitoring.

/**
 * Enable runtime domain for event monitoring
 * Implementation delegates to Runtime.enable()
 * @return Command to enable runtime events
 */
protected Command<Void> enableRuntime();

/**
 * Disable runtime domain to stop event monitoring
 * Implementation delegates to Runtime.disable()
 * @return Command to disable runtime events
 */
protected Command<Void> disableRuntime();

Console Event Monitoring

Monitor console API calls such as console.log(), console.error(), console.warn(), etc.

/**
 * Get the console API called event
 * Implementation delegates to Runtime.consoleAPICalled()
 * @return Event for monitoring console API calls
 */
protected Event<ConsoleAPICalled> consoleEvent();

/**
 * Convert CDP console event to Selenium ConsoleEvent
 * Handles timestamp conversion and remote object processing
 * @param event CDP ConsoleAPICalled event
 * @return Selenium ConsoleEvent with timestamp and arguments
 */
protected ConsoleEvent toConsoleEvent(ConsoleAPICalled event);

Usage Example:

import org.openqa.selenium.devtools.v133.v133Events;
import org.openqa.selenium.devtools.events.ConsoleEvent;
import org.openqa.selenium.devtools.v133.runtime.model.ConsoleAPICalled;

v133Events events = new v133Events(devTools);

// Listen for console events
devTools.addListener(events.consoleEvent(), (ConsoleAPICalled event) -> {
    ConsoleEvent consoleEvent = events.toConsoleEvent(event);
    System.out.println("Console: " + consoleEvent.getType() + 
                      " - " + consoleEvent.getMessages());
});

// Enable runtime to start receiving events
devTools.send(events.enableRuntime());

JavaScript Exception Handling

Monitor and process JavaScript exceptions with detailed stack traces and error information.

/**
 * Get the JavaScript exception thrown event
 * @return Event for monitoring JavaScript exceptions
 */
protected Event<ExceptionThrown> exceptionThrownEvent();

/**
 * Convert CDP exception event to Selenium JavascriptException
 * @param event CDP ExceptionThrown event  
 * @return JavascriptException with message and stack trace
 */
protected JavascriptException toJsException(ExceptionThrown event);

Usage Example:

import org.openqa.selenium.JavascriptException;
import org.openqa.selenium.devtools.v133.runtime.model.ExceptionThrown;

// Listen for JavaScript exceptions
devTools.addListener(events.exceptionThrownEvent(), (ExceptionThrown event) -> {
    JavascriptException jsException = events.toJsException(event);
    System.err.println("JavaScript Error: " + jsException.getMessage());
    jsException.printStackTrace();
});

Event Data Types

ConsoleAPICalled

Represents a console API call event from the browser runtime.

// From org.openqa.selenium.devtools.v133.runtime.model.ConsoleAPICalled
public class ConsoleAPICalled {
    public String getType();           // Type of console call (log, error, warn, etc.)
    public List<RemoteObject> getArgs(); // Arguments passed to console method
    public Timestamp getTimestamp();   // When the console call occurred
}

ExceptionThrown

Represents a JavaScript exception event with detailed error information.

// From org.openqa.selenium.devtools.v133.runtime.model.ExceptionThrown  
public class ExceptionThrown {
    public ExceptionDetails getExceptionDetails(); // Detailed exception information
}

public class ExceptionDetails {
    public String getText();                    // Exception message text
    public Integer getLineNumber();             // Line number where exception occurred
    public Optional<String> getUrl();          // URL of script where exception occurred
    public Optional<StackTrace> getStackTrace(); // JavaScript stack trace
    public Optional<RemoteObject> getException(); // Exception object details
}

Selenium Event Wrappers

The v133Events class converts CDP events to Selenium's standard event types:

// From org.openqa.selenium.devtools.events.ConsoleEvent
public class ConsoleEvent {
    public ConsoleEvent(String type, Instant timestamp, List<Object> messages, List<RemoteObject> originalArgs);
    public String getType();
    public Instant getTimestamp();
    public List<Object> getMessages();
}

// From org.openqa.selenium.JavascriptException
public class JavascriptException extends RuntimeException {
    public JavascriptException(String message);
    public void setStackTrace(StackTraceElement[] stackTrace);
}

Error Handling

The event system includes robust error handling for various scenarios:

  • Missing Stack Traces: When stack trace information is unavailable, creates placeholder stack elements
  • Timestamp Parsing: Handles timestamp conversion from CDP format to Java time types
  • Message Extraction: Safely extracts error messages from exception details with fallbacks

Integration with Base Events

The v133Events class integrates seamlessly with Selenium's base Events infrastructure, providing:

  • Type-safe event parameter mapping
  • Consistent event listener interfaces
  • Standardized error handling patterns
  • Cross-domain event coordination

Install with Tessl CLI

npx tessl i tessl/maven-org-seleniumhq-selenium--selenium-devtools-v133

docs

events.md

index.md

javascript.md

logging.md

network.md

targets.md

tile.json