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

Method onIntercept

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

* Handle Network interception requests * @param connection WebSocket connection to the browser * @param httpResponse Object representing what we are intercepting * as well as what should be returned. * @param callback callback called when we intercept requests.

(connection, httpResponse, callback)

Source from the content-addressed store, hash-verified

1441 * @param callback callback called when we intercept requests.
1442 */
1443 async onIntercept(connection, httpResponse, callback) {
1444 this._cdpWsConnection.on('message', (message) => {
1445 const params = JSON.parse(message)
1446 if (params.method === 'Fetch.requestPaused') {
1447 const requestPausedParams = params['params']
1448 if (requestPausedParams.request.url == httpResponse.urlToIntercept) {
1449 connection.execute('Fetch.fulfillRequest', {
1450 requestId: requestPausedParams['requestId'],
1451 responseCode: httpResponse.status,
1452 responseHeaders: httpResponse.headers,
1453 body: httpResponse.body,
1454 })
1455 callback()
1456 } else {
1457 connection.execute('Fetch.continueRequest', {
1458 requestId: requestPausedParams['requestId'],
1459 })
1460 }
1461 }
1462 })
1463
1464 await connection.execute('Fetch.enable', {}, null)
1465 await connection.execute(
1466 'Network.setCacheDisabled',
1467 {
1468 cacheDisabled: true,
1469 },
1470 null,
1471 )
1472 }
1473
1474 /**
1475 *

Callers 1

devtools_test.jsFile · 0.80

Calls 4

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

Tested by

no test coverage detected