namespace webdriver.logging
Defines WebDriver's logging system. The logging system is
broken into major components: local and remote logging.
The local logging API, which is anchored by the
Logger
class, is similar to Java's
logging API. Loggers, retrieved by webdriver.logging.getLogger
, use
hierarchical, dot-delimited namespaces
(e.g. "" > "webdriver" > "webdriver.logging"). Recorded log messages are
represented by the LogRecord
class. You
can capture log records by
attaching a handler function
to the desired logger. For convenience, you can quickly enable logging to
the console by simply calling
webdriver.logging.installConsoleHandler()
.
The remote logging API
allows you to retrieve logs from a remote WebDriver server. This API uses the
Preferences
class to define desired log levels prior to create a
WebDriver session:
var prefs = new webdriver.logging.Preferences();
prefs.setLevel(webdriver.logging.Type.BROWSER,
webdriver.logging.Level.DEBUG);
var caps = webdriver.Capabilities.chrome();
caps.setLoggingPrefs(prefs);
// ...
Remote log entries are represented by the Entry
class and may be
retrieved via webdriver.WebDriver.Logs
:
driver.manage().logs().get(webdriver.logging.Type.BROWSER)
.then(function(entries) {
entries.forEach(function(entry) {
console.log('[%s] %s', entry.level.name, entry.message);
});
});
NOTE: Only a few browsers support the remote logging API (notably
Firefox and Chrome). Firefox supports basic logging functionality, while
Chrome exposes robust
performance logging
options. Remote logging is still considered a non-standard feature, and the
APIs exposed by this module for it are non-frozen. Once logging is officially
defined by the W3C WebDriver spec, this
module will be updated to use a consistent API for local and remote logging.
Functions
addConsoleHandler(opt_logger)code »
Adds the console handler to the given logger. The console handler will log
all messages using the JavaScript Console API.
getLogger(opt_name)code »
Finds a named logger.
Parameters
- opt_name
string=
The dot-delimited logger name, such as
"webdriver.logging.Logger". Defaults to the name of the root logger.
installConsoleHandler()code »
Installs the console log handler on the root logger.
removeConsoleHandler(opt_logger)code »
Removes the console log handler from the given logger.
Types
- Entry
A single log entry recorded by a WebDriver component, such as a remote
WebDriver server.
- Level
The Level class defines a set of standard logging levels that
can be used to control logging output.
- LogRecord
LogRecord objects are used to pass logging requests between
the logging framework and individual log Handlers.
- Logger
The Logger is an object used for logging debug messages.
- Preferences
Describes the log preferences for a WebDriver session.
- Type
No description.