Skip to content

Commit

Permalink
[bidi][js] Add fail request command
Browse files Browse the repository at this point in the history
  • Loading branch information
pujagani committed Mar 14, 2024
1 parent b5ded12 commit 2b8fa0c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions javascript/node/selenium-webdriver/bidi/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] },
Expand Down

0 comments on commit 2b8fa0c

Please sign in to comment.