Closed baflQA closed 10 months ago
@baflQA, thank you for creating this issue. We will troubleshoot it as soon as we can.
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!
@baflQA
I think you are using the interceptor incorrectly, to modify the response you should use a Filter
and not a Route
.
This is a example how to modify the response, without the need to work with the Network.responseReceived()
:
https://github.com/SeleniumHQ/selenium/blob/938058d969de2d2512eb8e3a47acea022927c4f2/java/test/org/openqa/selenium/devtools/NetworkInterceptorTest.java#L188-L200
Hey. I don't have a access to my mac right nów, but it definitely works when you are running against the local browser. I try your suggestion later tough.
Hey @joerg1985 ! I've created an updated version of my test: https://github.com/baflQA/selenium-debug/blob/main/src/test/java/seleniumdebug/NetworkCapture2Test.java If You comment the line 55 and uncomment 56, the test will pass. But when You will run the runGridStandalone.sh script, and use the remote driver with the standalone grid, it will fail with the timeout. The page won't be even refreshed, the whole network traffic will be kind of blocked.
All the custom network capturing (enableInterception, captureResponse and extractAndModifyCapturedResponse) should be removed, to ensure the NetworkInterceptor is working correctly.
Ok, it should be like this now: https://github.com/baflQA/selenium-debug/blob/main/src/test/java/seleniumdebug/NetworkCapture2Test.java
But it doesn't help at all - it passes with the local browser, but completely freezes the network traffic when using selenium grid :/
Looks good now, i will try to debug into this the next days.
@baflQA, thank you for creating this issue. We will troubleshoot it as soon as we can.
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!
@baflQA With a local standalone server the code is working for me.
The server inside the container does not start for me, it only shows this error:
[joerg@mybox selenium-debug]$ podman container attach --latest
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.openqa.selenium.grid.Bootstrap.runMain(Bootstrap.java:77)
at org.openqa.selenium.grid.Bootstrap.main(Bootstrap.java:70)
Caused by: org.openqa.selenium.grid.config.ConfigException: Unable to parse: /opt/bin/config.toml
at org.openqa.selenium.grid.config.TomlConfig.from(TomlConfig.java:59)
at org.openqa.selenium.grid.config.Configs.from(Configs.java:39)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:550)
at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:517)
at org.openqa.selenium.grid.config.ConfigFlags.readConfigFiles(ConfigFlags.java:67)
at org.openqa.selenium.grid.TemplateGridCommand.lambda$configure$4(TemplateGridCommand.java:98)
at org.openqa.selenium.grid.Main.launch(Main.java:83)
at org.openqa.selenium.grid.Main.go(Main.java:56)
at org.openqa.selenium.grid.Main.main(Main.java:41)
... 6 more
2023-09-09 12:02:54,001 INFO exited: selenium-grid-docker (exit status 1; not expected)
Hey - i'm very sorry. I think that i broke the config with malformed logging property. I removed that. Can you please pull the master branch and try again? Apoligies once again. 🫣
@baflQA Seems like my podman is not able to run the selenium-server, so someone with docker installed should check this. I can not install it locally and i am out of space for a vm.
With a server started via java -jar ./selenium-server-4.12.1.jar standalone --selenium-manager true
the code is working for me. So you might check this if it is working for you with a locally started server, if so the error might be related to the docker setup.
Hey - yes, it does work with selenium server standalone indeed... It must be some kind of networking issue when running inside the docker. Maybe @diemol You could find some misconfiguration in my run grid script? Or maybe this is a bug somewhere in the Se?
Does it happen only with Dynamic Grid? What happens when you use a regular Grid with containers?
Hey - actually, it does not work when I run grid like this too:
docker network create grid
docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.12.1-20230904
docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub --shm-size="2g" -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e SE_NODE_GRID_URL=http://localhost:4444 selenium/node-chrome:4.12.1-20230904
It seems to be intercepting some network traffic (there are some logs in the console) but the navigation to the desired page is stuck, and finally I receive this error:
WARNING: Unable to process: {"method":"Fetch.requestPaused","params":{"requestId":"interception-job-1.0","request":{"url":"https://developer.mozilla.org/en-US/","method":"GET","headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36","sec-ch-ua":"\"Chromium\";v=\"116\", \"Not)A;Brand\";v=\"24\", \"Google Chrome\";v=\"116\"","sec-ch-ua-mobile":"?0","sec-ch-ua-platform":"\"Linux\""},"initialPriority":"VeryHigh","referrerPolicy":"strict-origin-when-cross-origin"},"frameId":"9AD2ADAE2966325149E9E5E070ABB9CD","resourceType":"Document"},"sessionId":"120CE7DDC668B0404D09279B87998A71"}
org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.12.1', revision: '8e34639b11'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.5.2', java.version: '11.0.20'
Driver info: driver.version: unknown
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:183)
at org.openqa.selenium.devtools.DevTools.send(DevTools.java:89)
at org.openqa.selenium.devtools.idealized.Network.lambda$prepareToInterceptTraffic$5(Network.java:258)
at org.openqa.selenium.devtools.Connection.lambda$handle$4(Connection.java:330)
[... java internals]
at org.openqa.selenium.devtools.Connection.handle(Connection.java:296)
at org.openqa.selenium.devtools.Connection.access$200(Connection.java:57)
at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:224)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:172)
... 19 more
which seems to be the same as from my Dynamic Grid
If everything works with the Standalone image, as a last experiment, what if you configure Hub and Node without Docker on different machines and see if it still happens? I want to discard Docker as something creating issues.
I'm sorry, but I'm afraid that's where I'm unable to provide feedback anymore :( My gut feeling tells me that there must be some docker networking issue, but I can not prove it. I hope that You guys will find this issue interesting and will be able to investigate it further. Anyway - appreciate for all Your effort so far.
It is interesting, but I don't have much time to troubleshoot during the next 2 weeks. I think verifying what I pointed out above will help to narrow down the root cause.
Could you please provide feedback anymore? If you need VMs, you can always use https://gitpod.io/
I'm not very familia with docker in generał, So i'm struggling a lot each Time when i play with the grid 😅 I will try to set up podman as you suggested. Any further hint what should i do further is welcome, e.g. what docker images do You have in mind precisely?
I meant to run the Grid with the plain Java jars on different machines to see if the issue is Docker or if the issue is in the Grid itself.
Ah, ok, cool, gonna try that in the evening!
Hey @diemol . I was able to run the hub on gitpod with
java -jar selenium-server-<version>.jar hub
but got problems with registering a node. Do You have some experience with doing that? The node keeps sending the registration event:
java -jar selenium-server.jar node --hub https://4444-baflqa-seleniumdebug-kbklvnm5cq6.ws-eu104.gitpod.io --selenium-manager true
22:10:42.967 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
22:10:42.970 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
22:10:43.049 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://4444-baflqa-seleniumdebug-kbklvnm5cq6.ws-eu104.gitpod.io:4442 and tcp://4444-baflqa-seleniumdebug-kbklvnm5cq6.ws-eu104.gitpod.io:4443
22:10:43.122 INFO [UnboundZmqEventBus.<init>] - Sockets created
22:10:44.128 INFO [UnboundZmqEventBus.<init>] - Event bus ready
22:10:44.220 INFO [NodeServer.createHandlers] - Reporting self as: http://192.168.5.178:5555
22:10:44.235 INFO [NodeOptions.getSessionFactories] - Detected 12 available processors
22:10:46.117 WARN [SeleniumManager.lambda$runCommand$1] - safaritp cannot be downloaded
22:10:46.148 INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge","ms:edgeOptions": {"args": ["--remote-allow-origins=*"]},"platformName": "mac"} 12 times
22:10:46.149 INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox","platformName": "mac"} 12 times
22:10:46.150 INFO [NodeOptions.report] - Adding Safari for {"browserName": "safari","platformName": "mac"} 1 times
22:10:46.151 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome","goog:chromeOptions": {"args": ["--remote-allow-origins=*"]},"platformName": "mac"} 12 times
22:10:46.185 INFO [Node.<init>] - Binding additional locator mechanisms: relative
22:10:46.318 INFO [NodeServer$1.start] - Starting registration process for Node http://192.168.5.178:5555
22:10:46.318 INFO [NodeServer.execute] - Started Selenium node 4.12.1 (revision 8e34639b11): http://192.168.5.178:5555
22:10:46.350 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
22:10:56.370 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
22:11:06.387 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
22:11:16.407 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
22:11:26.425 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
22:11:36.441 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
22:11:46.459 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Remote( command_executor='http://grid-hub-url:4444/wd/hub', desired_capabilities={'browserName': 'chrome'} )
driver.implicitly_wait(10)
wait = WebDriverWait(driver, 10) element = wait.until(EC.presence_of_element_located((By.ID, 'element_id')))
An update from my side:
I've used 2 physical machines in the local network.
The hub runs on machine A:
java -jar C:\selenium-server.jar hub
The node runs on machine B:
java -jar selenium-server.jar node --hub http://192.168.5.199:4444/ --selenium-manager true
my test code runs from the machine B, and creates a new webdriver instance like this:
var browser = new RemoteWebDriver(new URL("http://192.168.5.199:4444/"), new ChromeOptions());
and the test passes with no issue.
So, apparently, there is some misconfiguration/issue with docker networking.
Attaching a video: https://1drv.ms/v/s!AiWNyppx8L_0m4FtAFcNznGY4lFiNA?e=zB3ZIZ
Hey - the issue seems to be fixed with 4.15. I believe that this was fixed by https://github.com/SeleniumHQ/selenium/commit/5d44d125dfa5f2633a44ab2918eb9a8cb04ac09b. Anyway - happy to close that 😄
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
What happened?
I'm trying to capture and modify a network call. I've prepared a sample project to reproduce the issue. https://github.com/baflQA/selenium-debug First, I start the selenium grid using docker-selenium images (https://github.com/baflQA/selenium-debug/blob/main/runGridStandalone.sh) Then, I start a new browser. The driver is augmented, the devTool connection is initiated. I navigate to a webpage, and capture some response. I get this response data, and store it in a variable. Then, I modify captured response. Finally, I create a new NetworkInterceptor instance, in order to capture and replace the original response for a given request with the modified one. I try to refresh the page, but once the network interceptor is registered, all the network traffic will be blocked. As a result, there will be an error thrown:
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.5.1', java.version: '11.0.20' Driver info: driver.version: unknown at org.openqa.selenium.devtools.Connection$Listener.lambda$onText$0(Connection.java:227) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException Build info: version: '4.12.1', revision: '8e34639b11' System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '13.5.1', java.version: '11.0.20' Driver info: driver.version: unknown at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:183) at org.openqa.selenium.devtools.DevTools.send(DevTools.java:89) at org.openqa.selenium.devtools.idealized.Network.lambda$prepareToInterceptTraffic$5(Network.java:258) at org.openqa.selenium.devtools.Connection.lambda$handle$4(Connection.java:330) 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:177) at java.base/java.util.stream.ReferencePipeline$11$1.accept(ReferencePipeline.java:442)
The issue is not reproducible when a non-remote driver is used.
How can we reproduce the issue?
Relevant log output
Operating System
macOS
Selenium version
4.12.1
What are the browser(s) and version(s) where you see this issue?
Chrome 116
What are the browser driver(s) and version(s) where you see this issue?
Chrome 116
Are you using Selenium Grid?
4.12