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

Method onLogEvent

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

* * @param connection * @param callback * @returns {Promise }

(connection, callback)

Source from the content-addressed store, hash-verified

1478 * @returns {Promise<void>}
1479 */
1480 async onLogEvent(connection, callback) {
1481 this._cdpWsConnection.on('message', (message) => {
1482 const params = JSON.parse(message)
1483 if (params.method === 'Runtime.consoleAPICalled') {
1484 const consoleEventParams = params['params']
1485 let event = {
1486 type: consoleEventParams['type'],
1487 timestamp: new Date(consoleEventParams['timestamp']),
1488 args: consoleEventParams['args'],
1489 }
1490
1491 callback(event)
1492 }
1493
1494 if (params.method === 'Log.entryAdded') {
1495 const logEventParams = params['params']
1496 const logEntry = logEventParams['entry']
1497 let event = {
1498 level: logEntry['level'],
1499 timestamp: new Date(logEntry['timestamp']),
1500 message: logEntry['text'],
1501 }
1502
1503 callback(event)
1504 }
1505 })
1506 await connection.execute('Runtime.enable', {}, null)
1507 }
1508
1509 /**
1510 *

Callers

nothing calls this directly

Calls 4

callbackFunction · 0.85
executeMethod · 0.65
onMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected