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

Method onIntercept

javascript/selenium-webdriver/lib/webdriver.js:1405–1434  ·  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

1403 * @param callback callback called when we intercept requests.
1404 */
1405 async onIntercept(connection, httpResponse, callback) {
1406 this._cdpWsConnection.on('message', (message) => {
1407 const params = JSON.parse(message)
1408 if (params.method === 'Fetch.requestPaused') {
1409 const requestPausedParams = params['params']
1410 if (requestPausedParams.request.url == httpResponse.urlToIntercept) {
1411 connection.execute('Fetch.fulfillRequest', {
1412 requestId: requestPausedParams['requestId'],
1413 responseCode: httpResponse.status,
1414 responseHeaders: httpResponse.headers,
1415 body: httpResponse.body,
1416 })
1417 callback()
1418 } else {
1419 connection.execute('Fetch.continueRequest', {
1420 requestId: requestPausedParams['requestId'],
1421 })
1422 }
1423 }
1424 })
1425
1426 await connection.execute('Fetch.enable', {}, null)
1427 await connection.execute(
1428 'Network.setCacheDisabled',
1429 {
1430 cacheDisabled: true,
1431 },
1432 null,
1433 )
1434 }
1435
1436 /**
1437 *

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