What happened?
I'm using Selenium with Javascript.
async function mockResponseStatus(url: string){
const connection = await driver.createCDPConnection('page');
let httpResponse = new HttpResponse(url);
httpResponse.addHeaders("Content-Type", "application/json")
httpResponse.body = "test";
httpResponse.status = 404;
httpResponse.returnStatus = 404;
await driver.onIntercept(connection, httpResponse, async function () {
});
}
I'm trying to set up the interception but unfortunately it is always giving back status 200 - OK. I can set the body and headers but the status and method is always hardcoded.
I've checked out the code and it doesn't seem right:
https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/lib/webdriver.js

I can see that there were changes related to this method:

85a7856
It seems response code got hardcoded and method parameter omitted completely. Could you please fix the issue?
How can we reproduce the issue?
async function mockResponseStatus(url: string){
const connection = await driver.createCDPConnection('page');
let httpResponse = new HttpResponse(url);
httpResponse.addHeaders("Content-Type", "application/json")
httpResponse.body = "test";
httpResponse.status = 404;
httpResponse.returnStatus = 404;
await driver.onIntercept(connection, httpResponse, async function () {
});
}
Relevant log output
Response body in chrome browser is always:
test
Status is 200
Operating System
Windows 10
Selenium version
4.8.0
What are the browser(s) and version(s) where you see this issue?
109.0.5414.120
What are the browser driver(s) and version(s) where you see this issue?
109.0.5414.120
Are you using Selenium Grid?
no
What happened?
I'm using Selenium with Javascript.
async function mockResponseStatus(url: string){
const connection = await driver.createCDPConnection('page');
let httpResponse = new HttpResponse(url);
httpResponse.addHeaders("Content-Type", "application/json")
httpResponse.body = "test";
httpResponse.status = 404;
httpResponse.returnStatus = 404;
await driver.onIntercept(connection, httpResponse, async function () {
});
}
I'm trying to set up the interception but unfortunately it is always giving back status 200 - OK. I can set the body and headers but the status and method is always hardcoded.
I've checked out the code and it doesn't seem right:
https://github.com/SeleniumHQ/selenium/blob/trunk/javascript/node/selenium-webdriver/lib/webdriver.js
I can see that there were changes related to this method:

85a7856
It seems response code got hardcoded and method parameter omitted completely. Could you please fix the issue?
How can we reproduce the issue?
Relevant log output
Operating System
Windows 10
Selenium version
4.8.0
What are the browser(s) and version(s) where you see this issue?
109.0.5414.120
What are the browser driver(s) and version(s) where you see this issue?
109.0.5414.120
Are you using Selenium Grid?
no