* 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()
| 2351 | * @see Options#logs() |
| 2352 | */ |
| 2353 | class Logs { |
| 2354 | /** |
| 2355 | * @param {!WebDriver} driver The parent driver. |
| 2356 | * @private |
| 2357 | */ |
| 2358 | constructor(driver) { |
| 2359 | /** @private {!WebDriver} */ |
| 2360 | this.driver_ = driver |
| 2361 | } |
| 2362 | |
| 2363 | /** |
| 2364 | * Fetches available log entries for the given type. |
| 2365 | * |
| 2366 | * Note that log buffers are reset after each call, meaning that available |
| 2367 | * log entries correspond to those entries not yet returned for a given log |
| 2368 | * type. In practice, this means that this call will return the available log |
| 2369 | * entries since the last call, or from the start of the session. |
| 2370 | * |
| 2371 | * @param {!logging.Type} type The desired log type. |
| 2372 | * @return {!Promise<!Array.<!logging.Entry>>} A |
| 2373 | * promise that will resolve to a list of log entries for the specified |
| 2374 | * type. |
| 2375 | */ |
| 2376 | get(type) { |
| 2377 | let cmd = new command.Command(command.Name.GET_LOG).setParameter('type', type) |
| 2378 | return this.driver_.execute(cmd).then(function (entries) { |
| 2379 | return entries.map(function (entry) { |
| 2380 | if (!(entry instanceof logging.Entry)) { |
| 2381 | return new logging.Entry(entry['level'], entry['message'], entry['timestamp'], entry['type']) |
| 2382 | } |
| 2383 | return entry |
| 2384 | }) |
| 2385 | }) |
| 2386 | } |
| 2387 | |
| 2388 | /** |
| 2389 | * Retrieves the log types available to this driver. |
| 2390 | * @return {!Promise<!Array<!logging.Type>>} A |
| 2391 | * promise that will resolve to a list of available log types. |
| 2392 | */ |
| 2393 | getAvailableLogTypes() { |
| 2394 | return this.driver_.execute(new command.Command(command.Name.GET_AVAILABLE_LOG_TYPES)) |
| 2395 | } |
| 2396 | } |
| 2397 | |
| 2398 | /** |
| 2399 | * An interface for changing the focus of the driver to another frame or window. |
nothing calls this directly
no outgoing calls
no test coverage detected