MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / Logs

Class Logs

javascript/selenium-webdriver/lib/webdriver.js:2442–2485  ·  view source on GitHub ↗

* Interface for managing WebDriver log records. * * This class should never be instantiated directly. Instead, obtain an * instance with * * webdriver.manage().logs() * * @see WebDriver#manage() * @see Options#logs()

Source from the content-addressed store, hash-verified

2440 * @see Options#logs()
2441 */
2442class Logs {
2443 /**
2444 * @param {!WebDriver} driver The parent driver.
2445 * @private
2446 */
2447 constructor(driver) {
2448 /** @private {!WebDriver} */
2449 this.driver_ = driver
2450 }
2451
2452 /**
2453 * Fetches available log entries for the given type.
2454 *
2455 * Note that log buffers are reset after each call, meaning that available
2456 * log entries correspond to those entries not yet returned for a given log
2457 * type. In practice, this means that this call will return the available log
2458 * entries since the last call, or from the start of the session.
2459 *
2460 * @param {!logging.Type} type The desired log type.
2461 * @return {!Promise<!Array.<!logging.Entry>>} A
2462 * promise that will resolve to a list of log entries for the specified
2463 * type.
2464 */
2465 get(type) {
2466 let cmd = new command.Command(command.Name.GET_LOG).setParameter('type', type)
2467 return this.driver_.execute(cmd).then(function (entries) {
2468 return entries.map(function (entry) {
2469 if (!(entry instanceof logging.Entry)) {
2470 return new logging.Entry(entry['level'], entry['message'], entry['timestamp'], entry['type'])
2471 }
2472 return entry
2473 })
2474 })
2475 }
2476
2477 /**
2478 * Retrieves the log types available to this driver.
2479 * @return {!Promise<!Array<!logging.Type>>} A
2480 * promise that will resolve to a list of available log types.
2481 */
2482 getAvailableLogTypes() {
2483 return this.driver_.execute(new command.Command(command.Name.GET_AVAILABLE_LOG_TYPES))
2484 }
2485}
2486
2487/**
2488 * An interface for changing the focus of the driver to another frame or window.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected