Java 将FireFoxProfile与RemoteWebDriver、Selenium Grid2一起使用会导致功能异常

Java 将FireFoxProfile与RemoteWebDriver、Selenium Grid2一起使用会导致功能异常,java,selenium,selenium-grid,remotewebdriver,firefox-profile,Java,Selenium,Selenium Grid,Remotewebdriver,Firefox Profile,我试图以编程方式创建一个临时firefox配置文件,用于selenium grid2的selenium测试 下面是我当前正在运行的代码 DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName("firefox"); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference(PREFERENCE_

我试图以编程方式创建一个临时firefox配置文件,用于selenium grid2的selenium测试

下面是我当前正在运行的代码

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("firefox");
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference(PREFERENCE_NAME,userAgent.getUserAgentString());
capabilities.setCapability(FirefoxDriver.PROFILE,profile);
RemoteWebDriver driver = new RemoteWebDriver(url, capabilities);
如果有关概要文件的所有行都被注释掉,则将运行此代码。但是,按现状,它将导致此异常

Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities [{browserName=firefox, version=, platform=ANY, firefox_profile=UEsDBBQACAgIAFxzBEkAAAAAAAAAA...}]
我知道异常是指在selenium服务器上找不到匹配的功能设置。但是,它应该传输配置文件,而不是寻找匹配的配置文件。“firefox\u profile=”后面的字符串是“profile.toJson()”的输出,因此它在某种程度上似乎做得很正确。我就是不明白为什么服务器不接受它

这是我的selenium服务器启动脚本

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6565 -cp selenium-server-standalone-2.53.0.jar org.openqa.grid.selenium.GridLauncher -role node -nodeConfig nodeconfig.json -hub http://192.168.5.151:4444/grid/register
和节点配置文件

{
"capabilities": [
    {
    "browserName": "firefox",
    "nativeEvents": true,
    "acceptSslCerts": true,
    "javascriptEnabled": true,
    "takesScreenshot": true,
    "firefox_profile": "selenium",
    "version": "44.0",
    "platform": "WIN10",
    "maxInstances": 1,
    "firefox_binary": "C:\\Program Files\\Mozilla\ Firefox\\firefox.exe",
    "cleanSession": true,
    "file.download.supported": true,
    "file.download.watcher": "WindowsFirefoxDownloadWatcher",
    "file.download.directory": "C:\\Users\\IEUser\\Downloads"
    },
    {
    "browserName": "chrome",
    "nativeEvents": true,
    "maxInstances": 1,
    "platform": "WIN10",
    "webdriver.chrome.driver": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" 
    },
    {
    "browserName": "MicrosoftEdge",
    "nativeEvents": true,
    "maxInstances": 1,
    "platform": "WIN10"
    }
],

"configuration": 
    {
    "_comment" : "Windows 10 with file download support",
    "cleanUpCycle": 2000,
    "timeout": 0,
    "port": 5555,
    "host": ip,
    "register": true,
    "hubPort": 4444,
    "maxSessions": 1,
    "Dwebdriver.edge.driver=C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe": ""
    }
}
我对此进行了大量研究,没有发现任何/任何人有类似的问题。我可以通过直接在vm上创建概要文件并在启动脚本中指定它来选择概要文件。然而,这不是我想要的功能

任何帮助都将不胜感激!谢谢大家!

转发新会话时出错,找不到:功能[{browserName=firefox,版本=,平台=ANY

这基本上是网格告诉您,您请求网格分配一个可以运行firefox的节点(无论平台风格或版本号如何),但网格没有任何这样的节点可供使用(在节点配置JSON文件中,您已指定关键firefox_配置文件的值为“硒”

“firefox_配置文件”:“selenium”

不确定为什么要在JSON配置文件中设置此键

我知道异常是指它在selenium服务器上找不到匹配的功能设置。但是,它应该传输配置文件,而不是寻找匹配的配置文件

网格只有在找到与请求的功能匹配的节点时才会这样做。在您的情况下,网格无法找到与您请求的任何功能匹配的节点,因此配置文件将不会被传输(因为此时目标未知)


因此,您需要从node\u config JSON文件中删除密钥“firefox\u profile”才能正常工作。然后,firefox配置文件将转发到相关的特定节点,您的执行将开始使用您创建的firefox配置文件。

您认为它为什么应该将您的配置文件传输到网格?