* 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()
| 2314 | * @see Options#logs() |
| 2315 | */ |
| 2316 | class Logs { |
| 2317 | /** |
| 2318 | * @param {!WebDriver} driver The parent driver. |
| 2319 | * @private |
| 2320 | */ |
| 2321 | constructor(driver) { |
| 2322 | /** @private {!WebDriver} */ |
| 2323 | this.driver_ = driver |
| 2324 | } |
| 2325 | |
| 2326 | /** |
| 2327 | * Fetches available log entries for the given type. |
| 2328 | * |
| 2329 | * Note that log buffers are reset after each call, meaning that available |
| 2330 | * log entries correspond to those entries not yet returned for a given log |
| 2331 | * type. In practice, this means that this call will return the available log |
| 2332 | * entries since the last call, or from the start of the session. |
| 2333 | * |
| 2334 | * @param {!logging.Type} type The desired log type. |
| 2335 | * @return {!Promise<!Array.<!logging.Entry>>} A |
| 2336 | * promise that will resolve to a list of log entries for the specified |
| 2337 | * type. |
| 2338 | */ |
| 2339 | get(type) { |
| 2340 | let cmd = new command.Command(command.Name.GET_LOG).setParameter('type', type) |
| 2341 | return this.driver_.execute(cmd).then(function (entries) { |
| 2342 | return entries.map(function (entry) { |
| 2343 | if (!(entry instanceof logging.Entry)) { |
| 2344 | return new logging.Entry(entry['level'], entry['message'], entry['timestamp'], entry['type']) |
| 2345 | } |
| 2346 | return entry |
| 2347 | }) |
| 2348 | }) |
| 2349 | } |
| 2350 | |
| 2351 | /** |
| 2352 | * Retrieves the log types available to this driver. |
| 2353 | * @return {!Promise<!Array<!logging.Type>>} A |
| 2354 | * promise that will resolve to a list of available log types. |
| 2355 | */ |
| 2356 | getAvailableLogTypes() { |
| 2357 | return this.driver_.execute(new command.Command(command.Name.GET_AVAILABLE_LOG_TYPES)) |
| 2358 | } |
| 2359 | } |
| 2360 | |
| 2361 | /** |
| 2362 | * 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