Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: Selenium BIDI network interception facing an issue with the "network.provideResponse" method #14443

Closed
dineshkumar-kanniyammal opened this issue Aug 27, 2024 · 3 comments

Comments

@dineshkumar-kanniyammal
Copy link

dineshkumar-kanniyammal commented Aug 27, 2024

What happened?

Facing an error while modifying the incoming responses via network intercept

Caused by: org.openqa.selenium.bidi.BiDiException: {"type":"error","id":4,"error":"unsupported operation","message":""statusCode" not supported yet in network.provideResponse","stacktrace":"RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:193:5\nUnsupportedOperationError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:848:5\nprovideResponse@chrome://remote/content/webdriver-bidi/modules/root/network.sys.mjs:965:13\nhandleCommand@chrome://remote/content/shared/messagehandler/MessageHandler.sys.mjs:255:33\nexecute@chrome://remote/content/shared/webdriver/Session.sys.mjs:390:32\nonPacket@chrome://remote/content/webdriver-bidi/WebDriverBiDiConnection.sys.mjs:204:37\nonMessage@chrome://remote/content/server/WebSocketTransport.sys.mjs:127:18\nhandleEvent@chrome://remote/content/server/WebSocketTransport.sys.mjs:109:14\n"}
Build info: version: '4.23.0', revision: '4df0a231af'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '14.6.1', java.version: '17.0.5'
Driver info: driver.version: unknown
at org.openqa.selenium.bidi.Connection.sendAndWait(Connection.java:178)
at org.openqa.selenium.bidi.BiDi.send(BiDi.java:51)
at org.openqa.selenium.bidi.module.Network.provideResponse(Network.java:137)
at firefoxAutomation.BidiFirefoxMocking.lambda$0(BidiFirefoxMocking.java:157)
at org.openqa.selenium.bidi.Connection.lambda$handleEventResponse$7(Connection.java:387)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1850)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at org.openqa.selenium.bidi.Connection.handleEventResponse(Connection.java:367)
at org.openqa.selenium.bidi.Connection.handle(Connection.java:304)
at org.openqa.selenium.bidi.Connection$Listener.lambda$onText$0(Connection.java:277)
... 3 more

How can we reproduce the issue?

FirefoxOptions options = new FirefoxOptions();
options.setBrowserVersion("128.0");
options.setCapability("webSocketUrl", true);
WebDriver driver=new FirefoxDriver(options);
Network network = new Network(driver.getWindowHandle(),driver);
network.addIntercept(new AddInterceptParameters(InterceptPhase.RESPONSE_STARTED));
network.onResponseStarted(responseDetails -> {
if (responseDetails.getRequest().getUrl().contains("get?test=123")) {
	ProvideResponseParameters responseParams = new ProvideResponseParameters(responseDetails.getRequest().getRequestId()).statusCode(400);	
 network.provideResponse(responseParams);	    	
}else{
network.continueResponse(new ContinueResponseParameters(responseDetails.getRequest().getRequestId()));
}
}

Relevant log output

INFO: <- {"type":"error","id":4,"error":"unsupported operation","message":"\"statusCode\" not supported yet in network.provideResponse","stacktrace":"RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:193:5\nUnsupportedOperationError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:848:5\nprovideResponse@chrome://remote/content/webdriver-bidi/modules/root/network.sys.mjs:965:13\nhandleCommand@chrome://remote/content/shared/messagehandler/MessageHandler.sys.mjs:255:33\nexecute@chrome://remote/content/shared/webdriver/Session.sys.mjs:390:32\nonPacket@chrome://remote/content/webdriver-bidi/WebDriverBiDiConnection.sys.mjs:204:37\nonMessage@chrome://remote/content/server/WebSocketTransport.sys.mjs:127:18\nhandleEvent@chrome://remote/content/server/WebSocketTransport.sys.mjs:109:14\n"}
Exception in thread "BiDi Connection" org.openqa.selenium.bidi.BiDiException: Unable to process: {"type":"event","method":"network.responseStarted","params":{"context":"5bc2b1bb-029b-461f-b6e1-3acdc764b1fc","isBlocked":true,"navigation":"c755381b-50ab-4383-a163-23d63a1d32a5","redirectCount":0,"request":{"request":"13","url":"https://postman-echo.com/get?test=123","method":"GET","bodySize":0,"headersSize":512,"headers":[{"name":"Host","value":{"type":"string","value":"postman-echo.com"}},{"name":"User-Agent","value":{"type":"string","value":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0"}},{"name":"Accept","value":{"type":"string","value":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8"}},{"name":"Accept-Language","value":{"type":"string","value":"en-US,en;q=0.5"}},{"name":"Accept-Encoding","value":{"type":"string","value":"gzip, deflate, br, zstd"}},{"name":"Connection","value":{"type":"string","value":"keep-alive"}},{"name":"Upgrade-Insecure-Requests","value":{"type":"string","value":"1"}},{"name":"Sec-Fetch-Dest","value":{"type":"string","value":"document"}},{"name":"Sec-Fetch-Mode","value":{"type":"string","value":"navigate"}},{"name":"Sec-Fetch-Site","value":{"type":"string","value":"none"}},{"name":"Sec-Fetch-User","value":{"type":"string","value":"?1"}},{"name":"Priority","value":{"type":"string","value":"u=0, i"}}],"cookies":[],"timings":{"timeOrigin":0,"requestTime":1724764129624009,"redirectStart":0,"redirectEnd":0,"fetchStart":1724764129629199,"dnsStart":1724764129629199,"dnsEnd":1724764135974712,"connectStart":1724764135975110,"connectEnd":1724764139651225,"tlsStart":1724764137234283,"tlsEnd":1724764139651225,"requestStart":1724764139651615,"responseStart":1724764143238741,"responseEnd":1724764143238942}},"timestamp":1724764143242,"intercepts":["304dace9-a68c-4736-90b4-84460fa46b29"],"response":{"url":"https://postman-echo.com/get?test=123","protocol":"h2","status":200,"statusText":"","fromCache":false,"headers":[{"name":"date","value":{"type":"string","value":"Tue, 27 Aug 2024 13:09:03 GMT"}},{"name":"content-type","value":{"type":"string","value":"application/json; charset=utf-8"}},{"name":"content-length","value":{"type":"string","value":"852"}},{"name":"server","value":{"type":"string","value":"nginx/1.25.3"}},{"name":"etag","value":{"type":"string","value":"W/\"354-ZUDtfLtwoeqUvLck1T0Lh0ZzV1k\""}},{"name":"set-cookie","value":{"type":"string","value":"sails.sid=s%3AhIlfQ262Nj3dPZhF95ISyTBvqtQfwqhm.7tC8P%2BfNXPoad2o8cHtBYQMM%2BBQXFd5e3mw%2FNguN2tc; Path=/; HttpOnly"}},{"name":"X-Firefox-Spdy","value":{"type":"string","value":"h2"}}],"mimeType":"application/json;charset=utf-8","bytesReceived":333,"headersSize":333,"bodySize":0,"content":{"size":0}}}}
	at org.openqa.selenium.bidi.Connection$Listener.lambda$onText$0(Connection.java:279)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.openqa.selenium.bidi.BiDiException: {"type":"error","id":4,"error":"unsupported operation","message":"\"statusCode\" not supported yet in network.provideResponse","stacktrace":"RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:193:5\nUnsupportedOperationError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:848:5\nprovideResponse@chrome://remote/content/webdriver-bidi/modules/root/network.sys.mjs:965:13\nhandleCommand@chrome://remote/content/shared/messagehandler/MessageHandler.sys.mjs:255:33\nexecute@chrome://remote/content/shared/webdriver/Session.sys.mjs:390:32\nonPacket@chrome://remote/content/webdriver-bidi/WebDriverBiDiConnection.sys.mjs:204:37\nonMessage@chrome://remote/content/server/WebSocketTransport.sys.mjs:127:18\nhandleEvent@chrome://remote/content/server/WebSocketTransport.sys.mjs:109:14\n"}
Build info: version: '4.23.0', revision: '4df0a231af'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '14.6.1', java.version: '17.0.5'
Driver info: driver.version: unknown
	at org.openqa.selenium.bidi.Connection.sendAndWait(Connection.java:178)
	at org.openqa.selenium.bidi.BiDi.send(BiDi.java:51)
	at org.openqa.selenium.bidi.module.Network.provideResponse(Network.java:137)
	at firefoxAutomation.BidiFirefoxMocking.lambda$0(BidiFirefoxMocking.java:157)
	at org.openqa.selenium.bidi.Connection.lambda$handleEventResponse$7(Connection.java:387)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1850)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.openqa.selenium.bidi.Connection.handleEventResponse(Connection.java:367)
	at org.openqa.selenium.bidi.Connection.handle(Connection.java:304)
	at org.openqa.selenium.bidi.Connection$Listener.lambda$onText$0(Connection.java:277)
	... 3 more

Operating System

Macos

Selenium version

selenium-server-4.23.0.jar

What are the browser(s) and version(s) where you see this issue?

Firefox 128.0.3

What are the browser driver(s) and version(s) where you see this issue?

geckodriver 0.35.0

Are you using Selenium Grid?

No response

Copy link

@dineshkumar-kanniyammal, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@dineshkumar-kanniyammal dineshkumar-kanniyammal changed the title [🐛 Bug]: org.openqa.selenium.bidi.BiDiException [🐛 Bug]: **In Selenium BIDI network interception** Facing an issue with the "network.provideResponse" method Aug 28, 2024
@dineshkumar-kanniyammal dineshkumar-kanniyammal changed the title [🐛 Bug]: **In Selenium BIDI network interception** Facing an issue with the "network.provideResponse" method [🐛 Bug]: In Selenium BIDI network interception Facing an issue with the "network.provideResponse" method Aug 28, 2024
@dineshkumar-kanniyammal dineshkumar-kanniyammal changed the title [🐛 Bug]: In Selenium BIDI network interception Facing an issue with the "network.provideResponse" method [🐛 Bug]: Selenium BIDI network interception facing an issue with the "network.provideResponse" method Aug 28, 2024
@pujagani
Copy link
Contributor

pujagani commented Sep 9, 2024

Hey! The error message is indicating the correct problem. The command is not supported by the browser. BiDi is work in progress. Please refer to https://wpt.fyi/results/webdriver/tests/bidi/network/provide_response?label=master&label=stable&aligned to see what is supported in which version of BiDi.

@pujagani pujagani closed this as completed Sep 9, 2024
@pujagani
Copy link
Contributor

pujagani commented Sep 9, 2024

https://wpt.fyi/results/webdriver/tests/bidi/network/provide_response?label=master&label=stable&aligned - Status code is now supported is newer versions of Firefox. Please use that for your code to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants