Необходимо запустить хаб через конфигурационный файл. Необходимость в файле - указать свой матчер-класс в параметре “capabilityMatcher”.
import org.openqa.grid.internal.utils.DefaultCapabilityMatcher;
import java.util.Map;
public class MyCapabilityMatcher extends DefaultCapabilityMatcher {
private final String nodeName = “nodeName”;
@Override
public boolean matches(Map<String, Object> nodeCapability, Map<String, Object> clientCapability) {
boolean defaultChecks = super.matches(nodeCapability, clientCapability);
if (!clientCapability.containsKey(nodeName)){
return defaultChecks;
}
return (defaultChecks && nodeCapability.get(nodeName).equals(clientCapability.get(nodeName)));
}
}
Скомпилировал класс.
Файл hub.json вида:
{
“port”: 4443,
“newSessionWaitTimeout”: -1,
“servlets” : [],
“withoutServlets”: [],
“custom”: {},
“capabilityMatcher”: “MyCapabilityMatcher”,
“throwOnCapabilityNotPresent”: true,
“cleanUpCycle”: 5000,
“role”: “hub”,
“debug”: false,
“browserTimeout”: 0,
“timeout”: 1800
}
При запуске хаба (java -jar selenium-server-standalone-3.4.0.jar -role hub -hubConfig hub.json) ошибка:
Exception in thread “main” org.openqa.grid.common.exception.GridConfigurationException: Error with the JSON of the config : String MyCapabilityMatcher could not be coerced to class: java.lang.Class
at org.openqa.grid.internal.utils.configuration.GridHubConfiguration.loadFromJSON(GridHubConfiguration.java:160)
at org.openqa.grid.internal.utils.configuration.GridHubConfiguration.loadFromJSON(GridHubConfiguration.java:147)
at org.openqa.grid.selenium.GridLauncherV3$2.setConfiguration(GridLauncherV3.java:249)
at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.java:155)
at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:75)
Caused by: java.lang.RuntimeException: String MyCapabilityMatcher could not be coerced to class: java.lang.Class
at org.openqa.grid.internal.utils.configuration.GridHubConfiguration$SimpleClassNameAdapter.read(GridHubConfiguration.java:230)
at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.Gson.fromJson(Gson.java:887)
at com.google.gson.Gson.fromJson(Gson.java:952)
at com.google.gson.Gson.fromJson(Gson.java:925)
at org.openqa.grid.internal.utils.configuration.GridHubConfiguration.loadFromJSON(GridHubConfiguration.java:158)
… 4 more
Caused by: java.lang.ClassNotFoundException: MyCapabilityMatcher
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
Буду очень признателен за помощь.