diff --git a/javascript/node/selenium-webdriver/bidi/network.js b/javascript/node/selenium-webdriver/bidi/network.js index 468dd1dd5fda5..9a4755ddfec42 100644 --- a/javascript/node/selenium-webdriver/bidi/network.js +++ b/javascript/node/selenium-webdriver/bidi/network.js @@ -108,6 +108,22 @@ class Network { await this.bidi.send(command) } + async continueWithAuth(requestId, username, password) { + const command = { + method: 'network.continueWithAuth', + params: { + request: requestId.toString(), + action: 'provideCredentials', + credentials: { + type: 'password', + username: username, + password: password + }, + }, + } + await this.bidi.send(command) + } + async continueWithAuthNoCredentials(requestId) { const command = { method: 'network.continueWithAuth', diff --git a/javascript/node/selenium-webdriver/lib/test/fileserver.js b/javascript/node/selenium-webdriver/lib/test/fileserver.js index df85d16453877..82b010549e476 100644 --- a/javascript/node/selenium-webdriver/lib/test/fileserver.js +++ b/javascript/node/selenium-webdriver/lib/test/fileserver.js @@ -201,7 +201,7 @@ function sendBasicAuth(request, response) { const userNameAndPass = Buffer.from(match[1], 'base64').toString() const parts = userNameAndPass.split(':', 2) - if (parts[0] !== 'genie' && parts[1] !== 'bottle') { + if (parts[0] !== 'genie' || parts[1] !== 'bottle') { denyAccess() return } 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 d8a40a1267517..9373c79c6712d 100644 --- a/javascript/node/selenium-webdriver/test/bidi/network_commands_test.js +++ b/javascript/node/selenium-webdriver/test/bidi/network_commands_test.js @@ -59,7 +59,20 @@ suite( await network.removeIntercept(intercept) }) - xit('can continue without auth credentials ', async function () { + xit('can continue with auth credentials ', async function () { + await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) + + await network.authRequired(async (event) => { + await network.continueWithAuth(event.request.request, 'genie','bottle') + }) + await driver.get(Pages.basicAuth) + + await driver.wait(until.elementLocated(By.css('pre'))) + let source = await driver.getPageSource() + assert.equal(source.includes('Access granted'), true) + }) + + it('can continue without auth credentials ', async function () { await network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) await network.authRequired(async (event) => {