diff --git a/javascript/node/selenium-webdriver/bidi/network.js b/javascript/node/selenium-webdriver/bidi/network.js index 01c9688f77e68..27e9883ba74c7 100644 --- a/javascript/node/selenium-webdriver/bidi/network.js +++ b/javascript/node/selenium-webdriver/bidi/network.js @@ -136,6 +136,16 @@ class Network { await this.bidi.send(command) } + async failRequest(requestId) { + const command = { + method: 'network.failRequest', + params: { + request: requestId.toString(), + }, + } + await this.bidi.send(command) + } + async continueWithAuthNoCredentials(requestId) { const command = { method: 'network.continueWithAuth', diff --git a/javascript/node/selenium-webdriver/test/bidi/network_commands_test.js b/javascript/node/selenium-webdriver/test/bidi/network_commands_test.js index fa1aba7276e1e..5efbb94adcecb 100644 --- a/javascript/node/selenium-webdriver/test/bidi/network_commands_test.js +++ b/javascript/node/selenium-webdriver/test/bidi/network_commands_test.js @@ -98,6 +98,23 @@ suite( assert.strictEqual(e.name, 'TimeoutError') } }) + + xit('can fail request', async function () { + await network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)) + + await network.beforeRequestSent(async (event) => { + await network.failRequest(event.request.request) + }) + + await driver.manage().setTimeouts({ pageLoad: 5000 }) + + try { + await driver.get(Pages.basicAuth) + assert.fail('Page should not be loaded') + } catch (e) { + assert.strictEqual(e.name, 'TimeoutError') + } + }) }) }, { browsers: [Browser.FIREFOX] },