-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
RemoteWebDriver cannot be cast to HasDevTools #9803
Comments
Thank you for providing the details. I am sharing a working code snippet below that uses Augmenter. Essentially, Augmenter enhances the RemoteWebDriver to allow the use for DevTools apis.
Please try it out with Augmenter and provide feedback if the error still persists. Will be happy to dig into it. |
I added my source code to GitHub. Beware that you switch to the devTools Branch, I created the repo for another bug |
There is also a runconfig in the ressources folder called "Dev Tools Selenium 4 remote chrome" which maybe help you |
Thank you for sharing the details and the code. Appreciate it. I will try it out on my machine and revert. However, based on the error message shared, I had a question. What Java version do you use? I am suspecting a Java version issue, since Java 9 introduced modules. Similarly, Java 16 has modules as well that causes a similar error as you shared. |
Hi! I tried it with JDK 17 and JDK 11. Both not working, but get different error messages/exceptions. To get cucumber-java8 running with Java12+ you have to change the "Before lunch" actions in the run config. It's important to:
This is because of https://stackoverflow.com/questions/67787645/cucumber-kotlin-illegalstateexception-when-launching-test-via-intellij/67817085#67817085 With JDK-17: |
With JDK-11 I get the same error: `/usr/lib/jvm/java-11-openjdk-amd64/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:46279,suspend=y,server=n -Dbrowser=remote_chrome -DbaseURL=http://www.wikipedia.at -Ddriver.version=93.0 -Dbrowser.version=93.0 -Dselenium.grid=http://localhost:4444 -Dorg.jetbrains.run.directory=/home/boris/repos/selenium4_caps_bug/src/test/resources/features -javaagent:/home/boris/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -classpath /home/boris/repos/selenium4_caps_bug/target/test-classes:/home/boris/.m2/repository/io/cucumber/cucumber-java8/6.10.4/cucumber-java8-6.10.4.jar:/home/boris/.m2/repository/io/cucumber/cucumber-core/6.10.4/cucumber-core-6.10.4.jar:/home/boris/.m2/repository/io/cucumber/cucumber-gherkin/6.10.4/cucumber-gherkin-6.10.4.jar:/home/boris/.m2/repository/io/cucumber/cucumber-gherkin-messages/6.10.4/cucumber-gherkin-messages-6.10.4.jar:/home/boris/.m2/repository/io/cucumber/messages/15.0.0/messages-15.0.0.jar:/home/boris/.m2/repository/io/cucumber/tag-expressions/3.0.1/tag-expressions-3.0.1.jar:/home/boris/.m2/repository/io/cucumber/cucumber-expressions/10.3.0/cucumber-expressions-10.3.0.jar:/home/boris/.m2/repository/io/cucumber/datatable/3.5.0/datatable-3.5.0.jar:/home/boris/.m2/repository/io/cucumber/cucumber-plugin/6.10.4/cucumber-plugin-6.10.4.jar:/home/boris/.m2/repository/io/cucumber/docstring/6.10.4/docstring-6.10.4.jar:/home/boris/.m2/repository/io/cucumber/html-formatter/13.0.0/html-formatter-13.0.0.jar:/home/boris/.m2/repository/io/cucumber/create-meta/4.0.0/create-meta- Testing started at 16:23 ... Step failed |
To simplify I also tried your lightweight example and created a new repository |
Thank you for providing the details. However, still unable to reproduce the issue with the new repository as well. Which version of Grid are you running? I am running tests using the Java Selenium binding rc-1. The Grid runs in the Standalone mode:
I do not explicitly set the version on the client and the server-side and let the Grid figure out the best match. |
That's really weird, I was also running the selenium grid rc1 but the docker version.
I will keep on searching |
Now we found the issue. It works with the standalone version of selenium grid rc-1 but not with the docker-version. |
Essentially the same exception happens with OpenJDK 13.0.2+8, it depends on the JVM version number that you execute the remote driver in. |
When I run using
After digging for a while, I suspect the issue is probably related to port mapping done here and the response URI rewritten here which return the URI for the client to make the websocket connection with. The rewrite works well for all Grid modes and CDP, except when used with Docker and CDP. Essentially, the Grid(Standalone/Hub/Router) port needs to ensure correct forwarding to the newly created container port. Locally, if I hard code the container port and pass that in grid-url option while running the jar, the CDP connection is made properly and it does not throw an error. Though that is not the correct way of doing it and it will not work for multiple containers. It was for just locally figuring things out. |
So can you fix it or create concrete tasks how to fix it? |
I have shared the issue comment above with Diego. He is the core contributor and expert for selenium-docker. He mentioned he is aware of the issue and will help on the same. |
Hi, should I consider my problem as the same since I've got Selenoide and when I'm trying to get my DevTools I got
|
@korabel00 I have also run into that problem (not on Solenoid). |
Hello, I added bytebuddy maven dependency to the pom.xml but I got classCastException in line |
i have the same issue , running remote on selenoid
I am facing the error: selenium.version: 4.0.0 |
Absolutely the same |
I have spent two days on this problem.
|
@arsen-papoyan unfortunately it doesn't work for me. At least for Selenoid. |
This issue actually refers to two different situations: "RemoteWebDriver cannot be cast to HasDevTools" and the "Unable to establish websocket connection to http...". The commit fixes the latter. For the earlier, if you are facing that, please open a new issue with all the information requested in the template. The fix allows the websocket connection when interacting with WebDriver BiDi or CDP over Grid, which seems to be the actual issue being faced by the OP. Here is some context for the fix... It is important to note, that doing WebDriver BiDi or CDP over Dynamic Grid is only supported when all components are running in Docker. A mix is not possible due to the network complexities of Docker. This fix will be included in a bug release that will happen in the following days. |
I have opened #10132 for the casting part |
Hi all,
|
Hi @diemol !
|
Any update on this I am also facing an issue while executing my test on experitest platform browser? |
@boris779 please check https://github.com/SeleniumHQ/docker-selenium#grid-url-and-session-timeout @bachhavdipak please create a separate issue if the problem is different to this one. |
Is it possible to get DevTools for Selenoid (not Grid)? |
@a-tikhomirov yes, it works if I start my grid locally, or use an local WebDriver, but it does not work if I run the docker-version of selenium 4.1.1 # I created a github repo... it has two branches, main (with the working local grid method) and the docker branch. I only used the docker-compose up command and a lightweight toml config. Maybe I have done something wrong. |
I was able to get debugger address at Selenoid with Then create a connection And get DevTools with it Had a problem with new CdpVersionFinder()).match(...) tho. |
I have the same problem....connectiom redused. |
@boris779 did you find a solution through a docker implementation? |
Sadly not. I tried a lot of things I didn't made the dynamic grid get running (in linux/ubuntu) all the information getting the docker API accessible didn't worked. The only version I got running is the standalone variant, but this solution is not acceptable for our project. |
@JuanManuelCarames @boris779 |
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. |
When having a Dynamic Grid, and a user who wants to do CDP over Grid, we have the situation that the browser is not running on the same host where the Node receives the original CDP request. In this case, we are having a Node running on one host, and the browser in a different host/container. For this, a forward url is being added to identify this situation and redirect the request to the place where the browser is running. All this because it is not possible to access to the browser's debugger address remotely. Fixes SeleniumHQ#9803
🐛 Bug Report
It's not possible to use the DevTools with the RemoteDriver. I was told to use the HasDevTools Interface but it still not working when using a RemoteWebDriver (with a Grid)
Detailed steps to reproduce the behavior:
webDriver is RemoteWebDriver which is used in a SeleniumGrid Environment.
Java:
DevTools devTools = ((HasDevTools) webDriver).getDevTools();
Kotlin:
val devTools: DevTools = (webDriver as HasDevTools).devTools
Used Selenium Version: 4.0.0-rc-1 (also tested with beta-3 and beta-4)
Environment
OS: Ubuntu 21
Browser: Chrome
Browser version: > 87
Browser Driver version: >87
Language Bindings version: Java
The text was updated successfully, but these errors were encountered: