-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
[java]: add websocket-port
test and --connect-existing
check
#15462
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
I don't think the args can contain that flag. The service instances in Java creates args by each method in the builder, not by passing in an array of args directly. |
@titusfortner yes, that's true, do you know where and how should I access the builder args? Also, java bindings already used a different websocket port in case of BiDi, but it didn't had a check for |
args.add(String.format("--websocket-port=%d", wsPort)); | ||
// Check if we're connecting to an existing Firefox instance | ||
boolean connectExisting = false; | ||
for (String arg : args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be for (String arg : this.args) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joerg1985 this.args
is not accessible inside createArgs()
, is there any other way to access the passed args?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry my fault, this.getArgs()
should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even that doesn't works, I think we need to add a new method to the builder as Titus suggested.
// This avoids conflicts when multiple Firefox instances are started | ||
if (!connectExisting) { | ||
int wsPort = PortProber.findFreePort(); | ||
args.add(String.format("--websocket-port=%d", wsPort)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be two args like this and 0 will autoselect a free port:
args.add("--websocket-port");
args.add("0");
args.add(String.format("http://[::1]:%d", wsPort)); | ||
// Only allocate a free port for the websocket when not connecting to an existing instance | ||
// This avoids conflicts when multiple Firefox instances are started | ||
if (!connectExisting) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should check for "--websocket-port" here too, someone might want to select a specific port to forward it:
mozilla/geckodriver#2218 (comment)
So, the current code doesn't allow specifying either To support Then in the createArgs if the user defined the marionette port you pass that in instead of a websocket port |
641a3a3
to
15e4fdf
Compare
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Motivation and Context
Java fix for #15451.
Java already uses a free websocket port for new firefox webdriver sessions. This PR adds a check for the
--connect-existing
flag and a BiDi based test for multiple Firefox driver sessions.Types of changes
Checklist
PR Type
Bug fix, Tests
Description
Added a check for the
--connect-existing
flag inGeckoDriverService
to avoid websocket port conflicts.Enhanced logic to allocate websocket ports only when not connecting to an existing Firefox instance.
Introduced a BiDi-based test to verify multiple Firefox driver sessions with unique websocket ports.
Ensured proper validation of BiDi websocket URLs and port uniqueness in the new test.
Changes walkthrough 📝
GeckoDriverService.java
Add `--connect-existing` check and websocket port allocation logic
java/src/org/openqa/selenium/firefox/GeckoDriverService.java
--connect-existing
flag.instance.
instances.
FirefoxDriverConcurrentTest.java
Add BiDi test for multiple Firefox instances
java/test/org/openqa/selenium/firefox/FirefoxDriverConcurrentTest.java