我正在尝试使用Selenium网格设置自定义功能匹配器。 Selenium Server版本:3.141.59
下面是我的代码:
import org.openqa.grid.internal.utils.DefaultCapabilityMatcher;
import java.util.Map;
public class YtlcCapabilityMatcher extends DefaultCapabilityMatcher {
private final String deviceName = "deviceName";
@Override
public boolean matches(Map nodeCapability, Map requestedCapability) {
boolean basicChecks = super.matches(nodeCapability, requestedCapability);
if (! requestedCapability.containsKey(deviceName)){
//If the user didnt set the custom capability lets just return what the DefaultCapabilityMatcher
//would return. That way we are backward compatibility and arent breaking the default behavior of the
//grid
return basicChecks;
}
return (basicChecks && nodeCapability.get(deviceName).equals(requestedCapability.get(deviceName)));
}
这是我的配置JSON文件:
{
"host": "10.28.19.251",
"port": 4545,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher": "com.ytlctest.capability.YtlcCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 30000,
"browserTimeout": 120,
"timeout": 120,
"newSessionWaitTimeout": 120,
"maxSession": 1000,
"jettyMaxThreads":-1
}
我遇到以下错误:
线程“主”中的异常 org.openqa.grid.common.exception.GridConfigurationException: com.ytlctest.capability.YtlcCapabilityMatcher.class不能为 强制实例构建信息:版本:“ 3.141.59”,修订版: 'e82be7d358',时间:'2018-11-14T08:25:53'系统信息:主机: 'SN2YCVW1B0005',ip:'10 .10.1.251',操作系统名称:'Windows 8.1',o s.arch: 'amd64',os.version:'6.3',java.version:'1.8.0_212'驱动程序信息: driver.version:未知 在org.openqa.grid.internal.utils.configuration.json.CommonJsonConfigura tion.fromJson(CommonJsonConfiguration.java:52) 在org.openqa.grid.internal.utils.configuration.json.CommonJsonConfigura tion.fromResourceOrFile(CommonJsonConfiguration.java:41) 在org.openqa.grid.internal.utils.configuration.json.HubJsonConfiguratio n.loadFromResourceOrFile(HubJsonConfiguration.java:41) 在java.util.Optional.map(未知来源) 在org.openqa.grid.internal.utils.configuration.GridHubConfiguration。(GridHubConfiguration.java:106) 在org.openqa.grid.selenium.GridLauncherV3.lambda $ buildLaunchers $ 5(GridL auncherV3.java:259) 在org.openqa.grid.selenium.GridLauncherV3.lambda $ launch $ 0(GridLauncherV 3.java:86) 在java.util.Optional.map(未知来源) 在org.openqa.grid.selenium.GridLauncherV3.launch(GridLauncherV3.java:86 ) 在org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:70) 造成原因:org.openqa.selenium.json.JsonException: com.ytlctest.capability.YtlcC apabilityMatcher.class不能为 强制实例构建信息:版本:“ 3.141.59”,修订版: 'e82be7d358',时间:'2018-11-14T08:25:53'系统信息:主机: 'SN2YCVW1B0005',ip:'10 .10.1.251',操作系统名称:'Windows 8.1',o s.arch: 'amd64',os.version:'6.3',java.version:'1.8.0_212'驱动程序信息: driver.version:未知 在org.openqa.grid.common.GridConfiguredJson $ SimpleClassNameCoercer.lamb da $ apply $ 0(GridConfiguredJson.java:79) 在org.openqa.selenium.json.JsonTypeCoercer.lambda $ null $ 6(JsonTypeCoerce r.java:145) 在org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java: 126) 在org.openqa.selenium.json.InstanceCoercer.lambda $ apply $ 0(InstanceCoerc er.java:87) 在org.openqa.selenium.json.JsonTypeCoercer.lambda $ null $ 6(JsonTypeCoerce r.java:145) 在org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java: 126) 在org.openqa.selenium.json.JsonInput.read(JsonInput.java:280) 在org.openqa.grid.common.GridConfiguredJson.toType(GridConfiguredJson.j ava:56) 在org.openqa.grid.internal.utils.configuration.json.CommonJsonConfigura tion.fromJson(CommonJsonConfiguration.java:48) ...还有9个
我已将编译类文件放在“ com / ytlctest / capability”下。
请帮助!