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

Method setCacheBehavior

javascript/selenium-webdriver/bidi/network.js:371–395  ·  view source on GitHub ↗

* Sets the cache behavior for network requests. * * @param {string} behavior - The cache behavior ("default" or "bypass") * @param {Array } [contexts] - Optional array of browsing context IDs * @returns {Promise } A promise that resolves when the cache behavior is set * @t

(behavior, contexts = null)

Source from the content-addressed store, hash-verified

369 * @throws {Error} If behavior is invalid or context IDs are invalid
370 */
371 async setCacheBehavior(behavior, contexts = null) {
372 if (!Object.values(CacheBehavior).includes(behavior)) {
373 throw new Error(`Cache behavior must be either "${CacheBehavior.DEFAULT}" or "${CacheBehavior.BYPASS}"`)
374 }
375
376 const command = {
377 method: 'network.setCacheBehavior',
378 params: {
379 cacheBehavior: behavior,
380 },
381 }
382
383 if (contexts !== null) {
384 if (
385 !Array.isArray(contexts) ||
386 contexts.length === 0 ||
387 contexts.some((c) => typeof c !== 'string' || c.trim() === '')
388 ) {
389 throw new Error('Contexts must be an array of non-empty strings')
390 }
391 command.params.contexts = contexts
392 }
393
394 await this.bidi.send(command)
395 }
396
397 /**
398 * Unsubscribes from network events for all browsing contexts.

Callers 2

network_test.jsFile · 0.45
network_test.jsFile · 0.45

Calls 3

includesMethod · 0.80
valuesMethod · 0.80
sendMethod · 0.65

Tested by

no test coverage detected