-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selenium grid missing configuration for custom capabilities mutators #7478
Comments
@JonathanHallKJR can you provide an example with code of what you mean? |
@diemol My suggested fix was based on browsing the code so I haven't attempted to implement it and I may have missed something tracing the program flow. Essentially the proposal is to add to config for the hub a This is required by the w3c web driver specification if the intermediary node (grid hub)'s capabilityMatcher relies on custom extension capabilities to route the request. The mock up below hasn't been compiled but hopefully conveys enough of the intent. ExampleStart the hub {
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets": [],
"withoutServlets": [],
"custom": {},
"capabilityMatcher": "hudson.plugins.selenium.JenkinsCapabilityMatcher",
"capabilityMutator": "package.for.my.example.MyCapabilityFilter", // added
"throwOnCapabilityNotPresent": true,
"cleanUpCycle": 5000,
"role": "hub",
"debug": false,
"browserTimeout": 0,
"timeout": 1800
}
The mutator class would then be given access to change the capabilities just before their forwarded to hubs during the NewSessionPipeline#createNewSession package package.for.my.example;
import java.util.*;
import java.util.function.Function;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
public class MyCapabilityFilter implements Function<Capabilities, Capabilities> {
// todo: Could also add constructor like org.openqa.grid.selenium.node.ChromeMutator that would make this
// configurable through the hubConfig.json
// for the example the filter is hard coded.
static final String EXTENSION_CAPABILITY_PREFIX = "jenkins:";
@Override
public Capabilities apply(Capabilities capabilities) {
Map<String, Object> toReturn = new HashMap<>(capabilities.asMap());
List<String> toRemove = new LinkedList<>();
// find all capabilities starting with filtered prefix.
for (String k : toReturn.keySet()) {
if (k.startsWith(EXTENSION_CAPABILITY_PREFIX)) {
toRemove.add(k);
}
}
// Remove all matches
for (String r : toRemove) {
toReturn.remove(r);
}
return new ImmutableCapabilities(toReturn);
}
} |
Revisiting this since the code for Grid 3 is not in A There is a Not sure if all this would already cover this use case. @JonathanHallKJR, what do you think? |
Closing as we did not get more feedback. |
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. |
馃殌 Feature Proposal
Grid already allows configuration of a Custom Matcher in the hub's config json but if that custom matcher wants to make use of extension capabilities as part of the processing (allowed by w3c specification) but there is no configuration also allow a Capabilities Mutator.
Motivation
Selenium Grid appears to passes intermediary extension capabilities through to the nodes which is a violation of the w3c specification for New Session
Suggested fix
Selenium Grid does appears have mechanism to change capabilities with Capabilities Mutator, but it isn't configurable like the Capabilities Matcher.
I think it would be possible to use the existing CapabilitiesMutator logic:
org.openqa.selenium.remote.server.NewSessionPipeline#addCapabilitiesMutator
org.openqa.selenium.remote.server.NewSessionPipeline#createNewSession
Suggest adding new config option for
customMutator
like existingorg.openqa.grid.internal.utils.configuration.GridHubConfiguration#capabilityMatcher
Then when creating the NewSessionPipeline
org.openqa.selenium.remote.server.SeleniumServer#createPipeline
if the configuration is instance of GridHubConfiguration then register the customerMutatorThe text was updated successfully, but these errors were encountered: